Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

(no description)

File Size: 5839 lines (221 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 lib/typo3/class.t3lib_utility_debug.php

Defines 3 classes

t3lib_div:: (149 methods):
  _GP()
  _GPmerged()
  _GET()
  _POST()
  _GETset()
  removeXSS()
  gif_compress()
  png_to_gif_by_imagemagick()
  read_png_gif()
  fixed_lgd_cs()
  breakLinesForEmail()
  cmpIP()
  cmpIPv4()
  cmpIPv6()
  IPv6Hex2Bin()
  IPv6Bin2Hex()
  normalizeIPv6()
  compressIPv6()
  validIP()
  validIPv4()
  validIPv6()
  cmpFQDN()
  isOnCurrentHost()
  inList()
  rmFromList()
  expandList()
  intInRange()
  intval_positive()
  int_from_ver()
  compat_version()
  md5int()
  shortMD5()
  hmac()
  uniqueList()
  split_fileref()
  dirname()
  modifyHTMLColor()
  modifyHTMLColorAll()
  testInt()
  isFirstPartOfStr()
  formatSize()
  convertMicrotime()
  splitCalc()
  calcPriority()
  calcParenthesis()
  htmlspecialchars_decode()
  deHSCentities()
  slashJS()
  rawUrlEncodeJS()
  rawUrlEncodeFP()
  validEmail()
  isBrokenEmailEnvironment()
  normalizeMailAddress()
  formatForTextarea()
  strtoupper()
  strtolower()
  generateRandomBytes()
  generateRandomBytesOpenSsl()
  generateRandomBytesMcrypt()
  generateRandomBytesUrandom()
  generateRandomBytesFallback()
  getRandomHexString()
  underscoredToUpperCamelCase()
  underscoredToLowerCamelCase()
  camelCaseToLowerCaseUnderscored()
  lcfirst()
  isValidUrl()
  inArray()
  intExplode()
  revExplode()
  trimExplode()
  removeArrayEntryByValue()
  keepItemsInArray()
  implodeArrayForUrl()
  explodeUrl2Array()
  compileSelectedGetVarsFromArray()
  addSlashesOnArray()
  stripSlashesOnArray()
  slashArray()
  remapArrayKeys()
  array_merge_recursive_overrule()
  array_merge()
  arrayDiffAssocRecursive()
  csvValues()
  removeDotsFromTS()
  naturalKeySortRecursive()
  get_tag_attributes()
  split_tag_attributes()
  implodeAttributes()
  wrapJS()
  xml2tree()
  array2xml_cs()
  array2xml()
  xml2array()
  xml2arrayProcess()
  xmlRecompileFromStructValArray()
  xmlGetHeaderAttribs()
  minifyJavaScript()
  getUrl()
  writeFile()
  fixPermissions()
  writeFileToTypo3tempDir()
  mkdir()
  mkdir_deep()
  createDirectoryPath()
  rmdir()
  get_dirs()
  getFilesInDir()
  getAllFilesAndFoldersInPath()
  removePrefixPathFromList()
  fixWindowsFilePath()
  resolveBackPath()
  locationHeaderUrl()
  getMaxUploadFileSize()
  getBytesFromSizeMeasurement()
  getMaximumPathLength()
  createVersionNumberedFilename()
  getThisUrl()
  linkThisScript()
  linkThisUrl()
  getIndpEnv()
  isAllowedHostHeaderValue()
  milliseconds()
  clientInfo()
  getHostname()
  getFileAbsFileName()
  validPathStr()
  isAbsPath()
  isAllowedAbsPath()
  verifyFilenameAgainstDenyPattern()
  sanitizeLocalUrl()
  upload_copy_move()
  upload_to_tempfile()
  unlink_tempfile()
  tempnam()
  stdAuthCode()
  cHashParams()
  generateCHash()
  calculateCHash()
  hideIfNotTranslated()
  hideIfDefaultLanguage()
  readLLfile()
  readLLPHPfile()
  readLLXMLfile()
  llXmlAutoFileName()
  loadTCA()
  resolveSheetDefInDS()
  resolveAllSheetsInDS()
  callUserFunction()

named:: (31 methods):
  getUserObj()
  hasValidClassPrefix()
  getValidClassPrefixes()
  makeInstance()
  instantiateClass()
  getClassName()
  setSingletonInstance()
  addInstance()
  checkInstanceClassName()
  purgeInstances()
  makeInstanceService()
  requireOnce()
  requireFile()
  plainMailEncoded()
  quoted_printable()
  encodeHeader()
  substUrlsInPlainText()
  makeRedirectUrl()
  freetypeDpiComp()
  initSysLog()
  sysLog()
  devLog()
  deprecationLog()
  getDeprecationLogFileName()
  logDeprecatedFunction()
  arrayToLogString()
  imageMagickCommand()
  unQuoteFilenames()
  quoteJSvalue()
  cleanOutputBuffers()
  flushOutputBuffers()

named:: (31 methods):
  getUserObj()
  hasValidClassPrefix()
  getValidClassPrefixes()
  makeInstance()
  instantiateClass()
  getClassName()
  setSingletonInstance()
  addInstance()
  checkInstanceClassName()
  purgeInstances()
  makeInstanceService()
  requireOnce()
  requireFile()
  plainMailEncoded()
  quoted_printable()
  encodeHeader()
  substUrlsInPlainText()
  makeRedirectUrl()
  freetypeDpiComp()
  initSysLog()
  sysLog()
  devLog()
  deprecationLog()
  getDeprecationLogFileName()
  logDeprecatedFunction()
  arrayToLogString()
  imageMagickCommand()
  unQuoteFilenames()
  quoteJSvalue()
  cleanOutputBuffers()
  flushOutputBuffers()


Class: t3lib_div  - X-Ref

The legendary "t3lib_div" class - Miscellaneous functions for general purpose.
Most of the functions do not relate specifically to TYPO3
However a section of functions requires certain TYPO3 features available
See comments in the source.
You are encouraged to use this library in your own scripts!

USE:
The class is intended to be used without creating an instance of it.
So: Don't instantiate - call functions with "t3lib_div::" prefixed the function name.
So use t3lib_div::[method-name] to refer to the functions, eg. 't3lib_div::milliseconds()'

_GP($var)   X-Ref
Returns the 'GLOBAL' value of incoming data from POST or GET, with priority to POST (that is equalent to 'GP' order)
Strips slashes from all output, both strings and arrays.
To enhancement security in your scripts, please consider using t3lib_div::_GET or t3lib_div::_POST if you already
know by which method your data is arriving to the scripts!

param: string $var GET/POST var to return
return: mixed POST var named $var and if not set, the GET var of the same name.

_GPmerged($parameter)   X-Ref
Returns the global arrays $_GET and $_POST merged with $_POST taking precedence.

param: string $parameter Key (variable name) from GET or POST vars
return: array Returns the GET vars merged recursively onto the POST vars.

_GET($var = NULL)   X-Ref
Returns the global $_GET array (or value from) normalized to contain un-escaped values.
ALWAYS use this API function to acquire the GET variables!

param: string $var Optional pointer to value in GET array (basically name of GET var)
return: mixed If $var is set it returns the value of $_GET[$var]. If $var is NULL (default), returns $_GET itself. In any case *slashes are stipped from the output!*

_POST($var = NULL)   X-Ref
Returns the global $_POST array (or value from) normalized to contain un-escaped values.
ALWAYS use this API function to acquire the $_POST variables!

param: string $var Optional pointer to value in POST array (basically name of POST var)
return: mixed If $var is set it returns the value of $_POST[$var]. If $var is NULL (default), returns $_POST itself. In any case *slashes are stipped from the output!*

_GETset($inputGet, $key = '')   X-Ref
Writes input value to $_GET.

param: mixed $inputGet
param: string $key
return: void

removeXSS($string)   X-Ref
Wrapper for the RemoveXSS function.
Removes potential XSS code from an input string.

Using an external class by Travis Puderbaugh <kallahar@quickwired.com>

param: string $string Input string
return: string Input string with potential XSS code removed

gif_compress($theFile, $type)   X-Ref
Compressing a GIF file if not already LZW compressed.
This function is a workaround for the fact that ImageMagick and/or GD does not compress GIF-files to their minimun size (that is RLE or no compression used)

The function takes a file-reference, $theFile, and saves it again through GD or ImageMagick in order to compress the file
GIF:
If $type is not set, the compression is done with ImageMagick (provided that $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] is pointing to the path of a lzw-enabled version of 'convert') else with GD (should be RLE-enabled!)
If $type is set to either 'IM' or 'GD' the compression is done with ImageMagick and GD respectively
PNG:
No changes.

$theFile is expected to be a valid GIF-file!
The function returns a code for the operation.

param: string $theFile Filepath
param: string $type See description of function
return: string Returns "GD" if GD was used, otherwise "IM" if ImageMagick was used. If nothing done at all, it returns empty string.

png_to_gif_by_imagemagick($theFile)   X-Ref
Converts a png file to gif.
This converts a png file to gif IF the FLAG $GLOBALS['TYPO3_CONF_VARS']['FE']['png_to_gif'] is set TRUE.

param: string $theFile the filename with path
return: string new filename

read_png_gif($theFile, $output_png = FALSE)   X-Ref
Returns filename of the png/gif version of the input file (which can be png or gif).
If input file type does not match the wanted output type a conversion is made and temp-filename returned.

param: string $theFile Filepath of image file
param: boolean $output_png If set, then input file is converted to PNG, otherwise to GIF
return: string If the new image file exists, its filepath is returned

fixed_lgd_cs($string, $chars, $appendString = '...')   X-Ref
Truncates a string with appended/prepended "..." and takes current character set into consideration.

param: string $string string to truncate
param: integer $chars must be an integer with an absolute value of at least 4. if negative the string is cropped from the right end.
param: string $appendString appendix to the truncated string
return: string cropped string

breakLinesForEmail($str, $newlineChar = LF, $lineWidth = 76)   X-Ref
Breaks up a single line of text for emails

param: string $str The string to break up
param: string $newlineChar The string to implode the broken lines with (default/typically \n)
param: integer $lineWidth The line width
return: string reformatted text

cmpIP($baseIP, $list)   X-Ref
Match IP number with list of numbers with wildcard
Dispatcher method for switching into specialised IPv4 and IPv6 methods.

param: string $baseIP is the current remote IP address for instance, typ. REMOTE_ADDR
param: string $list is a comma-list of IP-addresses to match with. *-wildcard allowed instead of number, plus leaving out parts in the IP number is accepted as wildcard (eg. 192.168.*.* equals 192.168). If list is "*" no check is done and the function returns TRUE immediately. An empty list always returns FALSE.
return: boolean TRUE if an IP-mask from $list matches $baseIP

cmpIPv4($baseIP, $list)   X-Ref
Match IPv4 number with list of numbers with wildcard

param: string        $baseIP is the current remote IP address for instance, typ. REMOTE_ADDR
param: string        $list is a comma-list of IP-addresses to match with. *-wildcard allowed instead of number, plus leaving out parts in the IP number is accepted as wildcard (eg. 192.168.*.* equals 192.168), could also contain IPv6 addresses
return: boolean        TRUE if an IP-mask from $list matches $baseIP

cmpIPv6($baseIP, $list)   X-Ref
Match IPv6 address with a list of IPv6 prefixes

param: string $baseIP is the current remote IP address for instance
param: string $list is a comma-list of IPv6 prefixes, could also contain IPv4 addresses
return: boolean TRUE if an baseIP matches any prefix

IPv6Hex2Bin($hex)   X-Ref
Transform a regular IPv6 address from hex-representation into binary

param: string $hex IPv6 address in hex-presentation
return: string Binary representation (16 characters, 128 characters)

IPv6Bin2Hex($bin)   X-Ref
Transform an IPv6 address from binary to hex-representation

param: string $bin IPv6 address in hex-presentation
return: string Binary representation (16 characters, 128 characters)

normalizeIPv6($address)   X-Ref
Normalize an IPv6 address to full length

param: string $address Given IPv6 address
return: string Normalized address

compressIPv6($address)   X-Ref
Compress an IPv6 address to the shortest notation

param: string $address Given IPv6 address
return: string Compressed address

validIP($ip)   X-Ref
Validate a given IP address.

Possible format are IPv4 and IPv6.

param: string $ip IP address to be tested
return: boolean TRUE if $ip is either of IPv4 or IPv6 format.

validIPv4($ip)   X-Ref
Validate a given IP address to the IPv4 address format.

Example for possible format: 10.0.45.99

param: string $ip IP address to be tested
return: boolean TRUE if $ip is of IPv4 format.

validIPv6($ip)   X-Ref
Validate a given IP address to the IPv6 address format.

Example for possible format: 43FB::BB3F:A0A0:0 | ::1

param: string $ip IP address to be tested
return: boolean TRUE if $ip is of IPv6 format.

cmpFQDN($baseHost, $list)   X-Ref
Match fully qualified domain name with list of strings with wildcard

param: string $baseHost A hostname or an IPv4/IPv6-address (will by reverse-resolved; typically REMOTE_ADDR)
param: string $list A comma-list of domain names to match with. *-wildcard allowed but cannot be part of a string, so it must match the full host name (eg. myhost.*.com => correct, myhost.*domain.com => wrong)
return: boolean TRUE if a domain name mask from $list matches $baseIP

isOnCurrentHost($url)   X-Ref
Checks if a given URL matches the host that currently handles this HTTP request.
Scheme, hostname and (optional) port of the given URL are compared.

param: string $url: URL to compare with the TYPO3 request host
return: boolean Whether the URL matches the TYPO3 request host

inList($list, $item)   X-Ref
Check for item in list
Check if an item exists in a comma-separated list of items.

param: string $list comma-separated list of items (string)
param: string $item item to check for
return: boolean TRUE if $item is in $list

rmFromList($element, $list)   X-Ref
Removes an item from a comma-separated list of items.

param: string $element element to remove
param: string $list comma-separated list of items (string)
return: string new comma-separated list of items

expandList($list)   X-Ref
Expand a comma-separated list of integers with ranges (eg 1,3-5,7 becomes 1,3,4,5,7).
Ranges are limited to 1000 values per range.

param: string $list comma-separated list of integers with ranges (string)
return: string new comma-separated list of items

intInRange($theInt, $min, $max = 2000000000, $zeroValue = 0)   X-Ref
Forces the integer $theInt into the boundaries of $min and $max. If the $theInt is 'FALSE' then the $zeroValue is applied.

param: integer $theInt Input value
param: integer $min Lower limit
param: integer $max Higher limit
param: integer $zeroValue Default value if input is FALSE.
return: integer The input value forced into the boundaries of $min and $max

intval_positive($theInt)   X-Ref
Returns the $integer if greater than zero, otherwise returns zero.

param: integer $theInt Integer string to process
return: integer

int_from_ver($verNumberStr)   X-Ref
Returns an integer from a three part version number, eg '4.12.3' -> 4012003

param: string $verNumberStr Version number on format x.x.x
return: integer Integer version of version number (where each part can count to 999)

compat_version($verNumberStr)   X-Ref
Returns TRUE if the current TYPO3 version (or compatibility version) is compatible to the input version
Notice that this function compares branches, not versions (4.0.1 would be > 4.0.0 although they use the same compat_version)

param: string $verNumberStr    Minimum branch number required (format x.y / e.g. "4.0" NOT "4.0.0"!)
return: boolean Returns TRUE if this setup is compatible with the provided version number

md5int($str)   X-Ref
Makes a positive integer hash out of the first 7 chars from the md5 hash of the input

param: string $str String to md5-hash
return: integer Returns 28bit integer-hash

shortMD5($input, $len = 10)   X-Ref
Returns the first 10 positions of the MD5-hash        (changed from 6 to 10 recently)

param: string $input Input string to be md5-hashed
param: integer $len The string-length of the output
return: string Substring of the resulting md5-hash, being $len chars long (from beginning)

hmac($input, $additionalSecret = '')   X-Ref
Returns a proper HMAC on a given input string and secret TYPO3 encryption key.

param: string $input Input string to create HMAC from
param: string $additionalSecret additionalSecret to prevent hmac beeing used in a different context
return: string resulting (hexadecimal) HMAC currently with a length of 40 (HMAC-SHA-1)

uniqueList($in_list, $secondParameter = NULL)   X-Ref
Takes comma-separated lists and arrays and removes all duplicates
If a value in the list is trim(empty), the value is ignored.

param: string $in_list Accept multiple parameters which can be comma-separated lists of values and arrays.
param: mixed $secondParameter: Dummy field, which if set will show a warning!
return: string Returns the list without any duplicates of values, space around values are trimmed

split_fileref($fileref)   X-Ref
Splits a reference to a file in 5 parts

param: string $fileref Filename/filepath to be analysed
return: array Contains keys [path], [file], [filebody], [fileext], [realFileext]

dirname($path)   X-Ref
Returns the directory part of a path without trailing slash
If there is no dir-part, then an empty string is returned.
Behaviour:

'/dir1/dir2/script.php' => '/dir1/dir2'
'/dir1/' => '/dir1'
'dir1/script.php' => 'dir1'
'd/script.php' => 'd'
'/script.php' => ''
'' => ''

param: string $path Directory name / path
return: string Processed input value. See function description.

modifyHTMLColor($color, $R, $G, $B)   X-Ref
Modifies a HTML Hex color by adding/subtracting $R,$G and $B integers

param: string $color A hexadecimal color code, #xxxxxx
param: integer $R Offset value 0-255
param: integer $G Offset value 0-255
param: integer $B Offset value 0-255
return: string A hexadecimal color code, #xxxxxx, modified according to input vars

modifyHTMLColorAll($color, $all)   X-Ref
Modifies a HTML Hex color by adding/subtracting $all integer from all R/G/B channels

param: string $color A hexadecimal color code, #xxxxxx
param: integer $all Offset value 0-255 for all three channels.
return: string A hexadecimal color code, #xxxxxx, modified according to input vars

testInt($var)   X-Ref
Tests if the input can be interpreted as integer.

param: mixed $var Any input variable to test
return: boolean Returns TRUE if string is an integer

isFirstPartOfStr($str, $partStr)   X-Ref
Returns TRUE if the first part of $str matches the string $partStr

param: string $str Full string to check
param: string $partStr Reference string which must be found as the "first part" of the full string
return: boolean TRUE if $partStr was found to be equal to the first part of $str

formatSize($sizeInBytes, $labels = '')   X-Ref
Formats the input integer $sizeInBytes as bytes/kilobytes/megabytes (-/K/M)

param: integer $sizeInBytes Number of bytes to format.
param: string $labels Labels for bytes, kilo, mega and giga separated by vertical bar (|) and possibly encapsulated in "". Eg: " | K| M| G" (which is the default value)
return: string Formatted representation of the byte number, for output.

convertMicrotime($microtime)   X-Ref
Returns microtime input to milliseconds

param: string $microtime Microtime
return: integer Microtime input string converted to an integer (milliseconds)

splitCalc($string, $operators)   X-Ref
This splits a string by the chars in $operators (typical /+-*) and returns an array with them in

param: string $string Input string, eg "123 + 456 / 789 - 4"
param: string $operators Operators to split by, typically "/+-*"
return: array Array with operators and operands separated.

calcPriority($string)   X-Ref
Calculates the input by +,-,*,/,%,^ with priority to + and -

param: string $string Input string, eg "123 + 456 / 789 - 4"
return: integer Calculated value. Or error string.

calcParenthesis($string)   X-Ref
Calculates the input with parenthesis levels

param: string $string Input string, eg "(123 + 456) / 789 - 4"
return: integer Calculated value. Or error string.

htmlspecialchars_decode($value)   X-Ref
Inverse version of htmlspecialchars()

param: string $value Value where &gt;, &lt;, &quot; and &amp; should be converted to regular chars.
return: string Converted result.

deHSCentities($str)   X-Ref
Re-converts HTML entities if they have been converted by htmlspecialchars()

param: string $str String which contains eg. "&amp;amp;" which should stay "&amp;". Or "&amp;#1234;" to "&#1234;". Or "&amp;#x1b;" to "&#x1b;"
return: string Converted result.

slashJS($string, $extended = FALSE, $char = "'")   X-Ref
This function is used to escape any ' -characters when transferring text to JavaScript!

param: string $string String to escape
param: boolean $extended If set, also backslashes are escaped.
param: string $char The character to escape, default is ' (single-quote)
return: string Processed input string

rawUrlEncodeJS($str)   X-Ref
Version of rawurlencode() where all spaces (%20) are re-converted to space-characters.
Useful when passing text to JavaScript where you simply url-encode it to get around problems with syntax-errors, linebreaks etc.

param: string $str String to raw-url-encode with spaces preserved
return: string Rawurlencoded result of input string, but with all %20 (space chars) converted to real spaces.

rawUrlEncodeFP($str)   X-Ref
rawurlencode which preserves "/" chars
Useful when file paths should keep the "/" chars, but have all other special chars encoded.

param: string $str Input string
return: string Output string

validEmail($email)   X-Ref
Checking syntax of input email address

param: string $email Input string to evaluate
return: boolean Returns TRUE if the $email address (input string) is valid

isBrokenEmailEnvironment()   X-Ref
Checks if current e-mail sending method does not accept recipient/sender name
in a call to PHP mail() function. Windows version of mail() and mini_sendmail
program are known not to process such input correctly and they cause SMTP
errors. This function will return TRUE if current mail sending method has
problem with recipient name in recipient/sender argument for mail().

TODO: 4.3 should have additional configuration variable, which is combined
by || with the rest in this function.

return: boolean TRUE if mail() does not accept recipient name

normalizeMailAddress($address)   X-Ref
Changes from/to arguments for mail() function to work in any environment.

param: string $address Address to adjust
return: string Adjusted address

formatForTextarea($content)   X-Ref
Formats a string for output between <textarea>-tags
All content outputted in a textarea form should be passed through this function
Not only is the content htmlspecialchar'ed on output but there is also a single newline added in the top. The newline is necessary because browsers will ignore the first newline after <textarea> if that is the first character. Therefore better set it!

param: string $content Input string to be formatted.
return: string Formatted for <textarea>-tags

strtoupper($str)   X-Ref
Converts string to uppercase
The function converts all Latin characters (a-z, but no accents, etc) to
uppercase. It is safe for all supported character sets (incl. utf-8).
Unlike strtoupper() it does not honour the locale.

param: string $str Input string
return: string Uppercase String

strtolower($str)   X-Ref
Converts string to lowercase
The function converts all Latin characters (A-Z, but no accents, etc) to
lowercase. It is safe for all supported character sets (incl. utf-8).
Unlike strtolower() it does not honour the locale.

param: string $str Input string
return: string Lowercase String

generateRandomBytes($bytesToReturn)   X-Ref
Returns a string of highly randomized bytes (over the full 8-bit range).

Note: Returned values are not guaranteed to be crypto-safe,
most likely they are not, depending on the used retrieval method.

param: integer $bytesToReturn Number of characters (bytes) to return
return: string Random Bytes

generateRandomBytesOpenSsl($bytesToGenerate)   X-Ref
Generate random bytes using openssl if available

param: string $bytesToGenerate
return: string

generateRandomBytesMcrypt($bytesToGenerate, $randomSource)   X-Ref
Generate random bytes using mcrypt if available

param: $bytesToGenerate
param: $randomSource
return: string

generateRandomBytesUrandom($bytesToGenerate)   X-Ref
Read random bytes from /dev/urandom if it is accessible

param: $bytesToGenerate
return: string

generateRandomBytesFallback($bytesToReturn)   X-Ref
Generate pseudo random bytes as last resort

param: $bytesToReturn
return: string

getRandomHexString($count)   X-Ref
Returns a hex representation of a random byte string.

param: integer $count Number of hex characters to return
return: string Random Bytes

underscoredToUpperCamelCase($string)   X-Ref
Returns a given string with underscores as UpperCamelCase.
Example: Converts blog_example to BlogExample

param: string $string: String to be converted to camel case
return: string UpperCamelCasedWord

underscoredToLowerCamelCase($string)   X-Ref
Returns a given string with underscores as lowerCamelCase.
Example: Converts minimal_value to minimalValue

param: string $string: String to be converted to camel case
return: string lowerCamelCasedWord

camelCaseToLowerCaseUnderscored($string)   X-Ref
Returns a given CamelCasedString as an lowercase string with underscores.
Example: Converts BlogExample to blog_example, and minimalValue to minimal_value

param: string $string String to be converted to lowercase underscore
return: string lowercase_and_underscored_string

lcfirst($string)   X-Ref
Converts the first char of a string to lowercase if it is a latin character (A-Z).
Example: Converts "Hello World" to "hello World"

param: string $string The string to be used to lowercase the first character
return: string The string with the first character as lowercase

isValidUrl($url)   X-Ref
Checks if a given string is a Uniform Resource Locator (URL).

param: string $url The URL to be validated
return: boolean Whether the given URL is valid

inArray(array $in_array, $item)   X-Ref
Check if an string item exists in an array.
Please note that the order of function parameters is reverse compared to the PHP function in_array()!!!

Comparison to PHP in_array():
-> $array = array(0, 1, 2, 3);
-> variant_a := t3lib_div::inArray($array, $needle)
-> variant_b := in_array($needle, $array)
-> variant_c := in_array($needle, $array, TRUE)
+---------+-----------+-----------+-----------+
| $needle | variant_a | variant_b | variant_c |
+---------+-----------+-----------+-----------+
| '1a'    | FALSE     | TRUE      | FALSE     |
| ''      | FALSE     | TRUE      | FALSE     |
| '0'     | TRUE      | TRUE      | FALSE     |
| 0       | TRUE      | TRUE      | TRUE      |
+---------+-----------+-----------+-----------+

param: array $in_array one-dimensional array of items
param: string $item item to check for
return: boolean TRUE if $item is in the one-dimensional array $in_array

intExplode($delimiter, $string, $onlyNonEmptyValues = FALSE, $limit = 0)   X-Ref
Explodes a $string delimited by $delim and passes each item in the array through intval().
Corresponds to t3lib_div::trimExplode(), but with conversion to integers for all values.

param: string $delimiter Delimiter string to explode with
param: string $string The string to explode
param: boolean $onlyNonEmptyValues If set, all empty values (='') will NOT be set in output
param: integer $limit If positive, the result will contain a maximum of limit elements,
return: array Exploded values, all converted to integers

revExplode($delimiter, $string, $count = 0)   X-Ref
Reverse explode which explodes the string counting from behind.
Thus t3lib_div::revExplode(':','my:words:here',2) will return array('my:words','here')

param: string $delimiter Delimiter string to explode with
param: string $string The string to explode
param: integer $count Number of array entries
return: array Exploded values

trimExplode($delim, $string, $removeEmptyValues = FALSE, $limit = 0)   X-Ref
Explodes a string and trims all values for whitespace in the ends.
If $onlyNonEmptyValues is set, then all blank ('') values are removed.

param: string $delim Delimiter string to explode with
param: string $string The string to explode
param: boolean $removeEmptyValues If set, all empty values will be removed in output
param: integer $limit If positive, the result will contain a maximum of
return: array Exploded values

removeArrayEntryByValue(array $array, $cmpValue)   X-Ref
Removes the value $cmpValue from the $array if found there. Returns the modified array

param: array $array Array containing the values
param: string $cmpValue Value to search for and if found remove array entry where found.
return: array Output array with entries removed if search string is found

keepItemsInArray(array $array, $keepItems, $getValueFunc = NULL)   X-Ref
Filters an array to reduce its elements to match the condition.
The values in $keepItems can be optionally evaluated by a custom callback function.

Example (arguments used to call this function):
$array = array(
array('aa' => array('first', 'second'),
array('bb' => array('third', 'fourth'),
array('cc' => array('fifth', 'sixth'),
);
$keepItems = array('third');
$getValueFunc = create_function('$value', 'return $value[0];');

Returns:
array(
array('bb' => array('third', 'fourth'),
)

param: array $array: The initial array to be filtered/reduced
param: mixed $keepItems: The items which are allowed/kept in the array - accepts array or csv string
param: string $getValueFunc: (optional) Unique function name set by create_function() used to get the value to keep
return: array The filtered/reduced array with the kept items

implodeArrayForUrl($name, array $theArray, $str = '', $skipBlank = FALSE, $rawurlencodeParamName = FALSE)   X-Ref
Implodes a multidim-array into GET-parameters (eg. &param[key][key2]=value2&param[key][key3]=value3)

param: string $name Name prefix for entries. Set to blank if you wish none.
param: array $theArray The (multidimensional) array to implode
param: string $str (keep blank)
param: boolean $skipBlank If set, parameters which were blank strings would be removed.
param: boolean $rawurlencodeParamName If set, the param name itself (for example "param[key][key2]") would be rawurlencoded as well.
return: string Imploded result, fx. &param[key][key2]=value2&param[key][key3]=value3

explodeUrl2Array($string, $multidim = FALSE)   X-Ref
Explodes a string with GETvars (eg. "&id=1&type=2&ext[mykey]=3") into an array

param: string $string GETvars string
param: boolean $multidim If set, the string will be parsed into a multidimensional array if square brackets are used in variable names (using PHP function parse_str())
return: array Array of values. All values AND keys are rawurldecoded() as they properly should be. But this means that any implosion of the array again must rawurlencode it!

compileSelectedGetVarsFromArray($varList, array $getArray, $GPvarAlt = TRUE)   X-Ref
Returns an array with selected keys from incoming data.
(Better read source code if you want to find out...)

param: string $varList List of variable/key names
param: array $getArray Array from where to get values based on the keys in $varList
param: boolean $GPvarAlt If set, then t3lib_div::_GP() is used to fetch the value if not found (isset) in the $getArray
return: array Output array with selected variables.

addSlashesOnArray(array &$theArray)   X-Ref
AddSlash array
This function traverses a multidimensional array and adds slashes to the values.
NOTE that the input array is and argument by reference.!!
Twin-function to stripSlashesOnArray

param: array $theArray Multidimensional input array, (REFERENCE!)
return: array

stripSlashesOnArray(array &$theArray)   X-Ref
StripSlash array
This function traverses a multidimensional array and strips slashes to the values.
NOTE that the input array is and argument by reference.!!
Twin-function to addSlashesOnArray

param: array $theArray Multidimensional input array, (REFERENCE!)
return: array

slashArray(array $arr, $cmd)   X-Ref
Either slashes ($cmd=add) or strips ($cmd=strip) array $arr depending on $cmd

param: array $arr Multidimensional input array
param: string $cmd "add" or "strip", depending on usage you wish.
return: array

remapArrayKeys(&$array, $mappingTable)   X-Ref
Rename Array keys with a given mapping table

param: array    $array Array by reference which should be remapped
param: array    $mappingTable Array with remap information, array/$oldKey => $newKey)

array_merge_recursive_overrule(array $arr0, array $arr1, $notAddKeys = FALSE, $includeEmptyValues = TRUE, $enableUnsetFeature = TRUE)   X-Ref
Merges two arrays recursively and "binary safe" (integer keys are
overridden as well), overruling similar values in the first array
($arr0) with the values of the second array ($arr1)
In case of identical keys, ie. keeping the values of the second.

param: array $arr0 First array
param: array $arr1 Second array, overruling the first array
param: boolean $notAddKeys If set, keys that are NOT found in $arr0 (first array) will not be set. Thus only existing value can/will be overruled from second array.
param: boolean $includeEmptyValues If set, values from $arr1 will overrule if they are empty or zero. Default: TRUE
param: boolean $enableUnsetFeature If set, special values "__UNSET" can be used in the second array in order to unset array keys in the resulting array.
return: array Resulting array where $arr1 values has overruled $arr0 values

array_merge(array $arr1, array $arr2)   X-Ref
An array_merge function where the keys are NOT renumbered as they happen to be with the real php-array_merge function. It is "binary safe" in the sense that integer keys are overridden as well.

param: array $arr1 First array
param: array $arr2 Second array
return: array Merged result.

arrayDiffAssocRecursive(array $array1, array $array2)   X-Ref
Filters keys off from first array that also exist in second array. Comparison is done by keys.
This method is a recursive version of php array_diff_assoc()

param: array $array1 Source array
param: array $array2 Reduce source array by this array
return: array Source array reduced by keys also present in second array

csvValues(array $row, $delim = ',', $quote = '"')   X-Ref
Takes a row and returns a CSV string of the values with $delim (default is ,) and $quote (default is ") as separator chars.

param: array $row Input array of values
param: string $delim Delimited, default is comma
param: string $quote Quote-character to wrap around the values.
return: string A single line of CSV

removeDotsFromTS(array $ts)   X-Ref
Removes dots "." from end of a key identifier of TypoScript styled array.
array('key.' => array('property.' => 'value')) --> array('key' => array('property' => 'value'))

param: array $ts: TypoScript configuration array
return: array TypoScript configuration array without dots at the end of all keys

naturalKeySortRecursive(&$array)   X-Ref
Sorts an array by key recursive - uses natural sort order (aAbB-zZ)

param: array $array array to be sorted recursively, passed by reference
return: boolean TRUE if param is an array

get_tag_attributes($tag)   X-Ref
Returns an array with all attributes of the input HTML tag as key/value pairs. Attributes are only lowercase a-z
$tag is either a whole tag (eg '<TAG OPTION ATTRIB=VALUE>') or the parameter list (ex ' OPTION ATTRIB=VALUE>')
If an attribute is empty, then the value for the key is empty. You can check if it existed with isset()

param: string $tag HTML-tag string (or attributes only)
return: array Array with the attribute values.

split_tag_attributes($tag)   X-Ref
Returns an array with the 'components' from an attribute list from an HTML tag. The result is normally analyzed by get_tag_attributes
Removes tag-name if found

param: string $tag HTML-tag string (or attributes only)
return: array Array with the attribute values.

implodeAttributes(array $arr, $xhtmlSafe = FALSE, $dontOmitBlankAttribs = FALSE)   X-Ref
Implodes attributes in the array $arr for an attribute list in eg. and HTML tag (with quotes)

param: array $arr Array with attribute key/value pairs, eg. "bgcolor"=>"red", "border"=>0
param: boolean $xhtmlSafe If set the resulting attribute list will have a) all attributes in lowercase (and duplicates weeded out, first entry taking precedence) and b) all values htmlspecialchar()'ed. It is recommended to use this switch!
param: boolean $dontOmitBlankAttribs If TRUE, don't check if values are blank. Default is to omit attributes with blank values.
return: string Imploded attributes, eg. 'bgcolor="red" border="0"'

wrapJS($string, $linebreak = TRUE)   X-Ref
Wraps JavaScript code XHTML ready with <script>-tags
Automatic re-indenting of the JS code is done by using the first line as indent reference.
This is nice for indenting JS code with PHP code on the same level.

param: string $string JavaScript code
param: boolean $linebreak Wrap script element in line breaks? Default is TRUE.
return: string The wrapped JS code, ready to put into a XHTML page

xml2tree($string, $depth = 999)   X-Ref
Parses XML input into a PHP array with associative keys

param: string $string XML data input
param: integer $depth Number of element levels to resolve the XML into an array. Any further structure will be set as XML.
author: bisqwit at iki dot fi dot not dot for dot ads dot invalid / http://dk.php.net/xml_parse_into_struct + kasperYYYY@typo3.com
return: mixed The array with the parsed structure unless the XML parser returns with an error in which case the error message string is returned.

array2xml_cs(array $array, $docTag = 'phparray', array $options = array()   X-Ref
Turns PHP array into XML. See array2xml()

param: array $array The input PHP array with any kind of data; text, binary, integers. Not objects though.
param: string $docTag Alternative document tag. Default is "phparray".
param: array $options Options for the compilation. See array2xml() for description.
param: string $charset Forced charset to prologue
return: string An XML string made from the input content in the array.

array2xml(array $array, $NSprefix = '', $level = 0, $docTag = 'phparray', $spaceInd = 0, array $options = array()   X-Ref
Deprecated to call directly (unless you are aware of using XML prologues)! Use "array2xml_cs" instead (which adds an XML-prologue)

Converts a PHP array into an XML string.
The XML output is optimized for readability since associative keys are used as tag names.
This also means that only alphanumeric characters are allowed in the tag names AND only keys NOT starting with numbers (so watch your usage of keys!). However there are options you can set to avoid this problem.
Numeric keys are stored with the default tag name "numIndex" but can be overridden to other formats)
The function handles input values from the PHP array in a binary-safe way; All characters below 32 (except 9,10,13) will trigger the content to be converted to a base64-string
The PHP variable type of the data IS preserved as long as the types are strings, arrays, integers and booleans. Strings are the default type unless the "type" attribute is set.
The output XML has been tested with the PHP XML-parser and parses OK under all tested circumstances with 4.x versions. However, with PHP5 there seems to be the need to add an XML prologue a la <?xml version="1.0" encoding="[charset]" standalone="yes" ?> - otherwise UTF-8 is assumed! Unfortunately, many times the output from this function is used without adding that prologue meaning that non-ASCII characters will break the parsing!! This suchs of course! Effectively it means that the prologue should always be prepended setting the right characterset, alternatively the system should always run as utf-8!
However using MSIE to read the XML output didn't always go well: One reason could be that the character encoding is not observed in the PHP data. The other reason may be if the tag-names are invalid in the eyes of MSIE. Also using the namespace feature will make MSIE break parsing. There might be more reasons...

param: array $array The input PHP array with any kind of data; text, binary, integers. Not objects though.
param: string $NSprefix tag-prefix, eg. a namespace prefix like "T3:"
param: integer $level Current recursion level. Don't change, stay at zero!
param: string $docTag Alternative document tag. Default is "phparray".
param: integer $spaceInd If greater than zero, then the number of spaces corresponding to this number is used for indenting, if less than zero - no indentation, if zero - a single TAB is used
param: array $options Options for the compilation. Key "useNindex" => 0/1 (boolean: whether to use "n0, n1, n2" for num. indexes); Key "useIndexTagForNum" => "[tag for numerical indexes]"; Key "useIndexTagForAssoc" => "[tag for associative indexes"; Key "parentTagMap" => array('parentTag' => 'thisLevelTag')
param: array $stackData Stack data. Don't touch.
return: string An XML string made from the input content in the array.

xml2array($string, $NSprefix = '', $reportDocTag = FALSE)   X-Ref
Converts an XML string to a PHP array.
This is the reverse function of array2xml()
This is a wrapper for xml2arrayProcess that adds a two-level cache

param: string $string XML content to convert into an array
param: string $NSprefix The tag-prefix resolve, eg. a namespace like "T3:"
param: boolean $reportDocTag If set, the document tag will be set in the key "_DOCUMENT_TAG" of the output array
return: mixed If the parsing had errors, a string with the error message is returned. Otherwise an array with the content.

xml2arrayProcess($string, $NSprefix = '', $reportDocTag = FALSE)   X-Ref
Converts an XML string to a PHP array.
This is the reverse function of array2xml()

param: string $string XML content to convert into an array
param: string $NSprefix The tag-prefix resolve, eg. a namespace like "T3:"
param: boolean $reportDocTag If set, the document tag will be set in the key "_DOCUMENT_TAG" of the output array
return: mixed If the parsing had errors, a string with the error message is returned. Otherwise an array with the content.

xmlRecompileFromStructValArray(array $vals)   X-Ref
This implodes an array of XML parts (made with xml_parse_into_struct()) into XML again.

param: array $vals An array of XML parts, see xml2tree
return: string Re-compiled XML data.

xmlGetHeaderAttribs($xmlData)   X-Ref
Extracts the attributes (typically encoding and version) of an XML prologue (header).

param: string $xmlData XML data
return: array Attributes of the xml prologue (header)

minifyJavaScript($script, &$error = '')   X-Ref
Minifies JavaScript

param: string $script Script to minify
param: string $error Error message (if any)
return: string Minified script or source string if error happened

getUrl($url, $includeHeader = 0, $requestHeaders = FALSE, &$report = NULL)   X-Ref
Reads the file or url $url and returns the content
If you are having trouble with proxys when reading URLs you can configure your way out of that with settings like $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] etc.

param: string $url File/URL to read
param: integer $includeHeader Whether the HTTP header should be fetched or not. 0=disable, 1=fetch header+content, 2=fetch header only
param: array $requestHeaders HTTP headers to be used in the request
param: array $report Error code/message and, if $includeHeader is 1, response meta data (HTTP status and content type)
return: mixed The content from the resource given as input. FALSE if an error has occured.

writeFile($file, $content)   X-Ref
Writes $content to the file $file

param: string $file Filepath to write to
param: string $content Content to write
return: boolean TRUE if the file was successfully opened and written to.

fixPermissions($path, $recursive = FALSE)   X-Ref
Sets the file system mode and group ownership of a file or a folder.

param: string $path Path of file or folder, must not be escaped. Path can be absolute or relative
param: boolean $recursive If set, also fixes permissions of files and folders in the folder (if $path is a folder)
return: mixed TRUE on success, FALSE on error, always TRUE on Windows OS

writeFileToTypo3tempDir($filepath, $content)   X-Ref
Writes $content to a filename in the typo3temp/ folder (and possibly one or two subfolders...)
Accepts an additional subdirectory in the file path!

param: string $filepath Absolute file path to write to inside "typo3temp/". First part of this string must match PATH_site."typo3temp/"
param: string $content Content string to write
return: string Returns NULL on success, otherwise an error string telling about the problem.

mkdir($newFolder)   X-Ref
Wrapper function for mkdir.
Sets folder permissions according to $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']
and group ownership according to $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']

param: string $newFolder Absolute path to folder, see PHP mkdir() function. Removes trailing slash internally.
return: boolean TRUE if @mkdir went well!

mkdir_deep($directory, $deepDirectory = '')   X-Ref
Creates a directory - including parent directories if necessary and
sets permissions on newly created directories.

param: string $directory Target directory to create. Must a have trailing slash
param: string $deepDirectory Directory to create. This second parameter
return: void

createDirectoryPath($fullDirectoryPath)   X-Ref
Creates directories for the specified paths if they do not exist. This
functions sets proper permission mask but does not set proper user and
group.

param: string $fullDirectoryPath
return: string Path to the the first created directory in the hierarchy

rmdir($path, $removeNonEmpty = FALSE)   X-Ref
Wrapper function for rmdir, allowing recursive deletion of folders and files

param: string $path Absolute path to folder, see PHP rmdir() function. Removes trailing slash internally.
param: boolean $removeNonEmpty Allow deletion of non-empty directories
return: boolean TRUE if @rmdir went well!

get_dirs($path)   X-Ref
Returns an array with the names of folders in a specific path
Will return 'error' (string) if there were an error with reading directory content.

param: string $path Path to list directories from
return: array Returns an array with the directory entries as values. If no path, the return value is nothing.

getFilesInDir($path, $extensionList = '', $prependPath = FALSE, $order = '', $excludePattern = '')   X-Ref
Returns an array with the names of files in a specific path

param: string $path Is the path to the file
param: string $extensionList is the comma list of extensions to read only (blank = all)
param: boolean $prependPath If set, then the path is prepended the file names. Otherwise only the file names are returned in the array
param: string $order is sorting: 1= sort alphabetically, 'mtime' = sort by modification time.
param: string $excludePattern A comma separated list of file names to exclude, no wildcards
return: array Array of the files found

getAllFilesAndFoldersInPath(array $fileArr, $path, $extList = '', $regDirs = FALSE, $recursivityLevels = 99, $excludePattern = '')   X-Ref
Recursively gather all files and folders of a path.

param: array $fileArr Empty input array (will have files added to it)
param: string $path The path to read recursively from (absolute) (include trailing slash!)
param: string $extList Comma list of file extensions: Only files with extensions in this list (if applicable) will be selected.
param: boolean $regDirs If set, directories are also included in output.
param: integer $recursivityLevels The number of levels to dig down...
param: string $excludePattern regex pattern of files/directories to exclude
return: array An array with the found files/directories.

removePrefixPathFromList(array $fileArr, $prefixToRemove)   X-Ref
Removes the absolute part of all files/folders in fileArr

param: array $fileArr: The file array to remove the prefix from
param: string $prefixToRemove: The prefix path to remove (if found as first part of string!)
return: array The input $fileArr processed.

fixWindowsFilePath($theFile)   X-Ref
Fixes a path for windows-backslashes and reduces double-slashes to single slashes

param: string $theFile File path to process
return: string

resolveBackPath($pathStr)   X-Ref
Resolves "../" sections in the input path string.
For example "fileadmin/directory/../other_directory/" will be resolved to "fileadmin/other_directory/"

param: string $pathStr File path in which "/../" is resolved
return: string

locationHeaderUrl($path)   X-Ref
Prefixes a URL used with 'header-location' with 'http://...' depending on whether it has it already.
- If already having a scheme, nothing is prepended
- If having REQUEST_URI slash '/', then prefixing 'http://[host]' (relative to host)
- Otherwise prefixed with TYPO3_REQUEST_DIR (relative to current dir / TYPO3_REQUEST_DIR)

param: string $path URL / path to prepend full URL addressing to.
return: string

getMaxUploadFileSize($localLimit = 0)   X-Ref
Returns the maximum upload size for a file that is allowed. Measured in KB.
This might be handy to find out the real upload limit that is possible for this
TYPO3 installation. The first parameter can be used to set something that overrides
the maxFileSize, usually for the TCA values.

param: integer $localLimit: the number of Kilobytes (!) that should be used as
return: integer the maximum size of uploads that are allowed (measured in kilobytes)

getBytesFromSizeMeasurement($measurement)   X-Ref
Gets the bytes value from a measurement string like "100k".

param: string $measurement: The measurement (e.g. "100k")
return: integer The bytes value (e.g. 102400)

getMaximumPathLength()   X-Ref
Retrieves the maximum path length that is valid in the current environment.

return: integer The maximum available path length

createVersionNumberedFilename($file, $forceQueryString = FALSE)   X-Ref
Function for static version numbers on files, based on the filemtime

This will make the filename automatically change when a file is
changed, and by that re-cached by the browser. If the file does not
exist physically the original file passed to the function is
returned without the timestamp.

Behaviour is influenced by the setting
TYPO3_CONF_VARS[TYPO3_MODE][versionNumberInFilename]
= TRUE (BE) / "embed" (FE) : modify filename
= FALSE (BE) / "querystring" (FE) : add timestamp as parameter

param: string $file Relative path to file including all potential query parameters (not htmlspecialchared yet)
param: boolean $forceQueryString If settings would suggest to embed in filename, this parameter allows us to force the versioning to occur in the query string. This is needed for scriptaculous.js which cannot have a different filename in order to load its modules (?load=...)
return: Relative path with version filename including the timestamp

getThisUrl()   X-Ref
Returns the HOST+DIR-PATH of the current script (The URL, but without 'http://' and without script-filename)

return: string

linkThisScript(array $getParams = array()   X-Ref
Returns the link-url to the current script.
In $getParams you can set associative keys corresponding to the GET-vars you wish to add to the URL. If you set them empty, they will remove existing GET-vars from the current URL.
REMEMBER to always use htmlspecialchars() for content in href-properties to get ampersands converted to entities (XHTML requirement and XSS precaution)

param: array $getParams Array of GET parameters to include
return: string

linkThisUrl($url, array $getParams = array()   X-Ref
Takes a full URL, $url, possibly with a querystring and overlays the $getParams arrays values onto the quirystring, packs it all together and returns the URL again.
So basically it adds the parameters in $getParams to an existing URL, $url

param: string $url URL string
param: array $getParams Array of key/value pairs for get parameters to add/overrule with. Can be multidimensional.
return: string Output URL with added getParams.

getIndpEnv($getEnvName)   X-Ref
Abstraction method which returns System Environment Variables regardless of server OS, CGI/MODULE version etc. Basically this is SERVER variables for most of them.
This should be used instead of getEnv() and $_SERVER/ENV_VARS to get reliable values for all situations.

param: string $getEnvName Name of the "environment variable"/"server variable" you wish to use. Valid values are SCRIPT_NAME, SCRIPT_FILENAME, REQUEST_URI, PATH_INFO, REMOTE_ADDR, REMOTE_HOST, HTTP_REFERER, HTTP_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, QUERY_STRING, TYPO3_DOCUMENT_ROOT, TYPO3_HOST_ONLY, TYPO3_HOST_ONLY, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, _ARRAY
return: string Value based on the input key, independent of server/os environment.

isAllowedHostHeaderValue($hostHeaderValue)   X-Ref
Checks if the provided host header value matches the trusted hosts pattern.
If the pattern is not defined (which only can happen early in the bootstrap), deny any value.

param: string $hostHeaderValue HTTP_HOST header value as sent during the request (may include port)
return: bool

milliseconds()   X-Ref
Gets the unixtime as milliseconds.

return: integer The unixtime as milliseconds

clientInfo($useragent = '')   X-Ref
Client Browser Information

param: string $useragent Alternative User Agent string (if empty, t3lib_div::getIndpEnv('HTTP_USER_AGENT') is used)
return: array Parsed information about the HTTP_USER_AGENT in categories BROWSER, VERSION, SYSTEM and FORMSTYLE

getHostname($requestHost = TRUE)   X-Ref
Get the fully-qualified domain name of the host.

param: boolean $requestHost Use request host (when not in CLI mode).
return: string The fully-qualified host name.

getFileAbsFileName($filename, $onlyRelative = TRUE, $relToTYPO3_mainDir = FALSE)   X-Ref
Returns the absolute filename of a relative reference, resolves the "EXT:" prefix (way of referring to files inside extensions) and checks that the file is inside the PATH_site of the TYPO3 installation and implies a check with t3lib_div::validPathStr(). Returns FALSE if checks failed. Does not check if the file exists.

param: string $filename The input filename/filepath to evaluate
param: boolean $onlyRelative If $onlyRelative is set (which it is by default), then only return values relative to the current PATH_site is accepted.
param: boolean $relToTYPO3_mainDir If $relToTYPO3_mainDir is set, then relative paths are relative to PATH_typo3 constant - otherwise (default) they are relative to PATH_site
return: string Returns the absolute filename of $filename IF valid, otherwise blank string.

validPathStr($theFile)   X-Ref
Checks for malicious file paths.

Returns TRUE if no '//', '..', '\' or control characters are found in the $theFile.
This should make sure that the path is not pointing 'backwards' and further doesn't contain double/back slashes.
So it's compatible with the UNIX style path strings valid for TYPO3 internally.

param: string $theFile File path to evaluate
return: boolean TRUE, $theFile is allowed path string, FALSE otherwise

isAbsPath($path)   X-Ref
Checks if the $path is absolute or relative (detecting either '/' or 'x:/' as first part of string) and returns TRUE if so.

param: string $path File path to evaluate
return: boolean

isAllowedAbsPath($path)   X-Ref
Returns TRUE if the path is absolute, without backpath '..' and within the PATH_site OR within the lockRootPath

param: string $path File path to evaluate
return: boolean

verifyFilenameAgainstDenyPattern($filename)   X-Ref
Verifies the input filename against the 'fileDenyPattern'. Returns TRUE if OK.

param: string $filename File path to evaluate
return: boolean

sanitizeLocalUrl($url = '')   X-Ref
Checks if a given string is a valid frame URL to be loaded in the
backend.

param: string $url potential URL to check
return: string either $url if $url is considered to be harmless, or an

upload_copy_move($source, $destination)   X-Ref
Moves $source file to $destination if uploaded, otherwise try to make a copy

param: string $source Source file, absolute path
param: string $destination Destination file, absolute path
return: boolean Returns TRUE if the file was moved.

upload_to_tempfile($uploadedFileName)   X-Ref
Will move an uploaded file (normally in "/tmp/xxxxx") to a temporary filename in PATH_site."typo3temp/" from where TYPO3 can use it.
Use this function to move uploaded files to where you can work on them.
REMEMBER to use t3lib_div::unlink_tempfile() afterwards - otherwise temp-files will build up! They are NOT automatically deleted in PATH_site."typo3temp/"!

param: string $uploadedFileName The temporary uploaded filename, eg. $_FILES['[upload field name here]']['tmp_name']
return: string If a new file was successfully created, return its filename, otherwise blank string.

unlink_tempfile($uploadedTempFileName)   X-Ref
Deletes (unlink) a temporary filename in 'PATH_site."typo3temp/"' given as input.
The function will check that the file exists, is in PATH_site."typo3temp/" and does not contain back-spaces ("../") so it should be pretty safe.
Use this after upload_to_tempfile() or tempnam() from this class!

param: string $uploadedTempFileName Filepath for a file in PATH_site."typo3temp/". Must be absolute.
return: boolean Returns TRUE if the file was unlink()'ed

tempnam($filePrefix)   X-Ref
Create temporary filename (Create file with unique file name)
This function should be used for getting temporary file names - will make your applications safe for open_basedir = on
REMEMBER to delete the temporary files after use! This is done by t3lib_div::unlink_tempfile()

param: string $filePrefix Prefix to temp file (which will have no extension btw)
return: string result from PHP function tempnam() with PATH_site . 'typo3temp/' set for temp path.

stdAuthCode($uid_or_record, $fields = '', $codeLength = 8)   X-Ref
Standard authentication code (used in Direct Mail, checkJumpUrl and setfixed links computations)

param: mixed $uid_or_record Uid (integer) or record (array)
param: string $fields List of fields from the record if that is given.
param: integer $codeLength Length of returned authentication code.
return: string MD5 hash of 8 chars.

cHashParams($addQueryParams)   X-Ref
Splits the input query-parameters into an array with certain parameters filtered out.
Used to create the cHash value

param: string $addQueryParams Query-parameters: "&xxx=yyy&zzz=uuu"
return: array Array with key/value pairs of query-parameters WITHOUT a certain list of variable names (like id, type, no_cache etc.) and WITH a variable, encryptionKey, specific for this server/installation

generateCHash($addQueryParams)   X-Ref
Returns the cHash based on provided query parameters and added values from internal call

param: string $addQueryParams Query-parameters: "&xxx=yyy&zzz=uuu"
return: string Hash of all the values

calculateCHash($params)   X-Ref
Calculates the cHash based on the provided parameters

param: array $params Array of key-value pairs
return: string Hash of all the values

hideIfNotTranslated($l18n_cfg_fieldValue)   X-Ref
Responds on input localization setting value whether the page it comes from should be hidden if no translation exists or not.

param: integer $l18n_cfg_fieldValue Value from "l18n_cfg" field of a page record
return: boolean TRUE if the page should be hidden

hideIfDefaultLanguage($localizationConfiguration)   X-Ref
Returns true if the "l18n_cfg" field value is not set to hide
pages in the default language

param: int $localizationConfiguration
return: boolean

readLLfile($fileRef, $langKey, $charset = '', $errorMode = 0)   X-Ref
Includes a locallang file and returns the $LOCAL_LANG array found inside.

param: string $fileRef Input is a file-reference (see t3lib_div::getFileAbsFileName). That file is expected to be a 'locallang.php' file containing a $LOCAL_LANG array (will be included!) or a 'locallang.xml' file conataining a valid XML TYPO3 language structure.
param: string $langKey Language key
param: string $charset Character set (option); if not set, determined by the language key
param: integer $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
return: array Value of $LOCAL_LANG found in the included file. If that array is found it will returned.

readLLPHPfile($fileRef, $langKey, $charset = '')   X-Ref
Includes a locallang-php file and returns the $LOCAL_LANG array
Works only when the frontend or backend has been initialized with a charset conversion object. See first code lines.

param: string $fileRef Absolute reference to locallang-PHP file
param: string $langKey TYPO3 language key, eg. "dk" or "de" or "default"
param: string $charset Character set (optional)
return: array LOCAL_LANG array in return.

readLLXMLfile($fileRef, $langKey, $charset = '')   X-Ref
Includes a locallang-xml file and returns the $LOCAL_LANG array
Works only when the frontend or backend has been initialized with a charset conversion object. See first code lines.

param: string $fileRef Absolute reference to locallang-XML file
param: string $langKey TYPO3 language key, eg. "dk" or "de" or "default"
param: string $charset Character set (optional)
return: array LOCAL_LANG array in return.

llXmlAutoFileName($fileRef, $language, $sameLocation = FALSE)   X-Ref
Returns auto-filename for locallang-XML localizations.

param: string $fileRef Absolute file reference to locallang-XML file. Must be inside system/global/local extension
param: string $language Language key
param: boolean $sameLocation if TRUE, then locallang-XML localization file name will be returned with same directory as $fileRef
return: string Returns the filename reference for the language unless error occurred (or local mode is used) in which case it will be NULL

loadTCA($table)   X-Ref
Loads the $GLOBALS['TCA'] (Table Configuration Array) for the $table

Requirements:
1) must be configured table (the ctrl-section configured),
2) columns must not be an array (which it is always if whole table loaded), and
3) there is a value for dynamicConfigFile (filename in typo3conf)

Note: For the frontend this loads only 'ctrl' and 'feInterface' parts.
For complete TCA use $GLOBALS['TSFE']->includeTCA() instead.

param: string $table Table name for which to load the full TCA array part into $GLOBALS['TCA']
return: void

resolveSheetDefInDS($dataStructArray, $sheet = 'sDEF')   X-Ref
Looks for a sheet-definition in the input data structure array. If found it will return the data structure for the sheet given as $sheet (if found).
If the sheet definition is in an external file that file is parsed and the data structure inside of that is returned.

param: array $dataStructArray Input data structure, possibly with a sheet-definition and references to external data source files.
param: string $sheet The sheet to return, preferably.
return: array An array with two num. keys: key0: The data structure is returned in this key (array) UNLESS an error occurred in which case an error string is returned (string). key1: The used sheet key value!

resolveAllSheetsInDS(array $dataStructArray)   X-Ref
Resolves ALL sheet definitions in dataStructArray
If no sheet is found, then the default "sDEF" will be created with the dataStructure inside.

param: array $dataStructArray Input data structure, possibly with a sheet-definition and references to external data source files.
return: array Output data structure with all sheets resolved as arrays.

callUserFunction($funcName, &$params, &$ref, $checkPrefix = 'user_', $errorMode = 0)   X-Ref
Calls a user-defined function/method in class
Such a function/method should look like this: "function proc(&$params, &$ref)    {...}"

param: string $funcName Function/Method reference, '[file-reference":"]["&"]class/function["->"method-name]'. You can prefix this reference with "[file-reference]:" and t3lib_div::getFileAbsFileName() will then be used to resolve the filename and subsequently include it by "require_once()" which means you don't have to worry about including the class file either! Example: "EXT:realurl/class.tx_realurl.php:&tx_realurl->encodeSpURL". Finally; you can prefix the class name with "&" if you want to reuse a former instance of the same object call ("singleton").
param: mixed $params Parameters to be pass along (typically an array) (REFERENCE!)
param: mixed $ref Reference to be passed along (typically "$this" - being a reference to the calling object) (REFERENCE!)
param: string $checkPrefix Alternative allowed prefix of class or function name
param: integer $errorMode Error mode (when class/function could not be found): 0 - call debug(), 1 - do nothing, 2 - raise an exception (allows to call a user function that may return FALSE)
return: mixed Content from method/function call or FALSE if the class/method/function was not found

Class: named  - X-Ref

getUserObj($classRef, $checkPrefix = 'user_', $silent = FALSE)   X-Ref
Creates and returns reference to a user defined object.
This function can return an object reference if you like. Just prefix the function call with "&": "$objRef = &t3lib_div::getUserObj('EXT:myext/class.tx_myext_myclass.php:&tx_myext_myclass');". This will work ONLY if you prefix the class name with "&" as well. See description of function arguments.

param: string $classRef Class reference, '[file-reference":"]["&"]class-name'. You can prefix the class name with "[file-reference]:" and t3lib_div::getFileAbsFileName() will then be used to resolve the filename and subsequently include it by "require_once()" which means you don't have to worry about including the class file either! Example: "EXT:realurl/class.tx_realurl.php:&tx_realurl". Finally; for the class name you can prefix it with "&" and you will reuse the previous instance of the object identified by the full reference string (meaning; if you ask for the same $classRef later in another place in the code you will get a reference to the first created one!).
param: string $checkPrefix Required prefix of class name. By default "tx_" and "Tx_" are allowed.
param: boolean $silent If set, no debug() error message is shown if class/function is not present.
return: object The instance of the class asked for. Instance is created with t3lib_div::makeInstance

hasValidClassPrefix($classRef, array $additionalPrefixes = array()   X-Ref
Checks if a class or function has a valid prefix: tx_, Tx_ or custom, e.g. user_

param: string $classRef The class or function to check
param: array $additionalPrefixes Additional allowed prefixes, mostly this will be user_
return: bool TRUE if name is allowed

getValidClassPrefixes()   X-Ref
Returns all valid class prefixes.

return: array Array of valid prefixed of class names

makeInstance($className)   X-Ref
Creates an instance of a class taking into account the class-extensions
API of TYPO3. USE THIS method instead of the PHP "new" keyword.
Eg. "$obj = new myclass;" should be "$obj = t3lib_div::makeInstance("myclass")" instead!

You can also pass arguments for a constructor:
t3lib_div::makeInstance('myClass', $arg1, $arg2, ..., $argN)

param: string $className
return: object the created instance

instantiateClass($className, $arguments)   X-Ref
Speed optimized alternative to ReflectionClass::newInstanceArgs()

param: string $className Name of the class to instantiate
param: array $arguments Arguments passed to self::makeInstance() thus the first one with index 0 holds the requested class name
return: mixed

getClassName($className)   X-Ref
Returns the class name for a new instance, taking into account the
class-extension API.

param: string $className Base class name to evaluate
return: string Final class name to instantiate with "new [classname]"

setSingletonInstance($className, t3lib_Singleton $instance)   X-Ref
Sets the instance of a singleton class to be returned by makeInstance.

If this function is called multiple times for the same $className,
makeInstance will return the last set instance.

Warning: This is a helper method for unit tests. Do not call this directly in production code!

param: string $className
param: t3lib_Singleton $instance
return: void

addInstance($className, $instance)   X-Ref
Sets the instance of a non-singleton class to be returned by makeInstance.

If this function is called multiple times for the same $className,
makeInstance will return the instances in the order in which they have
been added (FIFO).

Warning: This is a helper method for unit tests. Do not call this directly in production code!

param: string $className
param: object $instance
return: void

checkInstanceClassName($className, $instance)   X-Ref
Checks that $className is non-empty and that $instance is an instance of
$className.

param: string $className a class name
param: object $instance an object
return: void

purgeInstances()   X-Ref
Purge all instances returned by makeInstance.

This function is most useful when called from tearDown in a test case
to drop any instances that have been created by the tests.

Warning: This is a helper method for unit tests. Do not call this directly in production code!

return: void

makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()   X-Ref
Find the best service and check if it works.
Returns object of the service class.

param: string $serviceType Type of service (service key).
param: string $serviceSubType Sub type like file extensions or similar. Defined by the service.
param: mixed $excludeServiceKeys List of service keys which should be excluded in the search for a service. Array or comma list.
return: object The service object or an array with error info's.

requireOnce($requireFile)   X-Ref
Require a class for TYPO3
Useful to require classes from inside other classes (not global scope). A limited set of global variables are available (see function)

param: string $requireFile: Path of the file to be included
return: void

requireFile($requireFile)   X-Ref
Requires a class for TYPO3
Useful to require classes from inside other classes (not global scope).
A limited set of global variables are available (see function)

param: string $requireFile: Path of the file to be included
return: void

plainMailEncoded($email, $subject, $message, $headers = '', $encoding = 'quoted-printable', $charset = '', $dontEncodeHeader = FALSE)   X-Ref
Simple substitute for the PHP function mail() which allows you to specify encoding and character set
The fifth parameter ($encoding) will allow you to specify 'base64' encryption for the output (set $encoding=base64)
Further the output has the charset set to UTF-8 by default.

param: string $email Email address to send to. (see PHP function mail())
param: string $subject Subject line, non-encoded. (see PHP function mail())
param: string $message Message content, non-encoded. (see PHP function mail())
param: string $headers Headers, separated by LF
param: string $encoding Encoding type: "base64", "quoted-printable", "8bit". Default value is "quoted-printable".
param: string $charset Charset used in encoding-headers (only if $encoding is set to a valid value which produces such a header)
param: boolean $dontEncodeHeader If set, the header content will not be encoded.
return: boolean TRUE if mail was accepted for delivery, FALSE otherwise

quoted_printable($string, $maxlen = 76)   X-Ref
Implementation of quoted-printable encode.
See RFC 1521, section 5.1 Quoted-Printable Content-Transfer-Encoding

param: string $string Content to encode
param: integer $maxlen Length of the lines, default is 76
return: string The QP encoded string

encodeHeader($line, $enc = 'quoted-printable', $charset = 'utf-8')   X-Ref
Encode header lines
Email headers must be ASCII, therefore they will be encoded to quoted_printable (default) or base64.

param: string $line Content to encode
param: string $enc Encoding type: "base64" or "quoted-printable". Default value is "quoted-printable".
param: string $charset Charset used for encoding
return: string The encoded string

substUrlsInPlainText($message, $urlmode = '76', $index_script_url = '')   X-Ref
Takes a clear-text message body for a plain text email, finds all 'http://' links and if they are longer than 76 chars they are converted to a shorter URL with a hash parameter. The real parameter is stored in the database and the hash-parameter/URL will be redirected to the real parameter when the link is clicked.
This function is about preserving long links in messages.

param: string $message Message content
param: string $urlmode URL mode; "76" or "all"
param: string $index_script_url URL of index script (see makeRedirectUrl())
return: string Processed message content

makeRedirectUrl($inUrl, $l = 0, $index_script_url = '')   X-Ref
Sub-function for substUrlsInPlainText() above.

param: string $inUrl Input URL
param: integer $l URL string length limit
param: string $index_script_url URL of "index script" - the prefix of the "?RDCT=..." parameter. If not supplied it will default to t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php'
return: string Processed URL

freetypeDpiComp($font_size)   X-Ref
Function to compensate for FreeType2 96 dpi

param: integer $font_size Fontsize for freetype function call
return: integer Compensated fontsize based on $GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi']

initSysLog()   X-Ref
Initialize the system log.

return: void

sysLog($msg, $extKey, $severity = 0)   X-Ref
Logs message to the system log.
This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors.
If you want to implement the sysLog in your applications, simply add lines like:
t3lib_div::sysLog('[write message in English here]', 'extension_key', 'severity');

param: string $msg Message (in English).
param: string $extKey Extension key (from which extension you are calling the log) or "Core"
param: integer $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is error, 4 is fatal error
return: void

devLog($msg, $extKey, $severity = 0, $dataVar = FALSE)   X-Ref
Logs message to the development log.
This should be implemented around the source code, both frontend and backend, logging everything from the flow through an application, messages, results from comparisons to fatal errors.
The result is meant to make sense to developers during development or debugging of a site.
The idea is that this function is only a wrapper for external extensions which can set a hook which will be allowed to handle the logging of the information to any format they might wish and with any kind of filter they would like.
If you want to implement the devLog in your applications, simply add lines like:
if (TYPO3_DLOG)    t3lib_div::devLog('[write message in english here]', 'extension key');

param: string $msg Message (in english).
param: string $extKey Extension key (from which extension you are calling the log)
param: integer $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message
param: mixed $dataVar Additional data you want to pass to the logger.
return: void

deprecationLog($msg)   X-Ref
Writes a message to the deprecation log.

param: string $msg Message (in English).
return: void

getDeprecationLogFileName()   X-Ref
Gets the absolute path to the deprecation log file.

return: string absolute path to the deprecation log file

logDeprecatedFunction()   X-Ref
Logs a call to a deprecated function.
The log message will be taken from the annotation.

return: void

arrayToLogString(array $arr, $valueList = array()   X-Ref
Converts a one dimensional array to a one line string which can be used for logging or debugging output
Example: "loginType: FE; refInfo: Array; HTTP_HOST: www.example.org; REMOTE_ADDR: 192.168.1.5; REMOTE_HOST:; security_level:; showHiddenRecords: 0;"

param: array $arr Data array which should be outputted
param: mixed $valueList List of keys which should be listed in the output string. Pass a comma list or an array. An empty list outputs the whole array.
param: integer $valueLength Long string values are shortened to this length. Default: 20
return: string Output string with key names and their value as string

imageMagickCommand($command, $parameters, $path = '')   X-Ref
Compile the command for running ImageMagick/GraphicsMagick.

param: string $command Command to be run: identify, convert or combine/composite
param: string $parameters The parameters string
param: string $path Override the default path (e.g. used by the install tool)
return: string Compiled command that deals with IM6 & GraphicsMagick

unQuoteFilenames($parameters, $unQuote = FALSE)   X-Ref
Explode a string (normally a list of filenames) with whitespaces by considering quotes in that string. This is mostly needed by the imageMagickCommand function above.

param: string $parameters The whole parameters string
param: boolean $unQuote If set, the elements of the resulting array are unquoted.
return: array Exploded parameters

quoteJSvalue($value)   X-Ref
Quotes a string for usage as JS parameter.

param: string $value the string to encode, may be empty
return: string the encoded value already quoted (with single quotes),

cleanOutputBuffers()   X-Ref
Ends and cleans all output buffers

return: void

flushOutputBuffers()   X-Ref
Ends and flushes all output buffers

return: void

Class: named  - X-Ref

getUserObj($classRef, $checkPrefix = 'user_', $silent = FALSE)   X-Ref
Creates and returns reference to a user defined object.
This function can return an object reference if you like. Just prefix the function call with "&": "$objRef = &t3lib_div::getUserObj('EXT:myext/class.tx_myext_myclass.php:&tx_myext_myclass');". This will work ONLY if you prefix the class name with "&" as well. See description of function arguments.

param: string $classRef Class reference, '[file-reference":"]["&"]class-name'. You can prefix the class name with "[file-reference]:" and t3lib_div::getFileAbsFileName() will then be used to resolve the filename and subsequently include it by "require_once()" which means you don't have to worry about including the class file either! Example: "EXT:realurl/class.tx_realurl.php:&tx_realurl". Finally; for the class name you can prefix it with "&" and you will reuse the previous instance of the object identified by the full reference string (meaning; if you ask for the same $classRef later in another place in the code you will get a reference to the first created one!).
param: string $checkPrefix Required prefix of class name. By default "tx_" and "Tx_" are allowed.
param: boolean $silent If set, no debug() error message is shown if class/function is not present.
return: object The instance of the class asked for. Instance is created with t3lib_div::makeInstance

hasValidClassPrefix($classRef, array $additionalPrefixes = array()   X-Ref
Checks if a class or function has a valid prefix: tx_, Tx_ or custom, e.g. user_

param: string $classRef The class or function to check
param: array $additionalPrefixes Additional allowed prefixes, mostly this will be user_
return: bool TRUE if name is allowed

getValidClassPrefixes()   X-Ref
Returns all valid class prefixes.

return: array Array of valid prefixed of class names

makeInstance($className)   X-Ref
Creates an instance of a class taking into account the class-extensions
API of TYPO3. USE THIS method instead of the PHP "new" keyword.
Eg. "$obj = new myclass;" should be "$obj = t3lib_div::makeInstance("myclass")" instead!

You can also pass arguments for a constructor:
t3lib_div::makeInstance('myClass', $arg1, $arg2, ..., $argN)

param: string $className
return: object the created instance

instantiateClass($className, $arguments)   X-Ref
Speed optimized alternative to ReflectionClass::newInstanceArgs()

param: string $className Name of the class to instantiate
param: array $arguments Arguments passed to self::makeInstance() thus the first one with index 0 holds the requested class name
return: mixed

getClassName($className)   X-Ref
Returns the class name for a new instance, taking into account the
class-extension API.

param: string $className Base class name to evaluate
return: string Final class name to instantiate with "new [classname]"

setSingletonInstance($className, t3lib_Singleton $instance)   X-Ref
Sets the instance of a singleton class to be returned by makeInstance.

If this function is called multiple times for the same $className,
makeInstance will return the last set instance.

Warning: This is a helper method for unit tests. Do not call this directly in production code!

param: string $className
param: t3lib_Singleton $instance
return: void

addInstance($className, $instance)   X-Ref
Sets the instance of a non-singleton class to be returned by makeInstance.

If this function is called multiple times for the same $className,
makeInstance will return the instances in the order in which they have
been added (FIFO).

Warning: This is a helper method for unit tests. Do not call this directly in production code!

param: string $className
param: object $instance
return: void

checkInstanceClassName($className, $instance)   X-Ref
Checks that $className is non-empty and that $instance is an instance of
$className.

param: string $className a class name
param: object $instance an object
return: void

purgeInstances()   X-Ref
Purge all instances returned by makeInstance.

This function is most useful when called from tearDown in a test case
to drop any instances that have been created by the tests.

Warning: This is a helper method for unit tests. Do not call this directly in production code!

return: void

makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()   X-Ref
Find the best service and check if it works.
Returns object of the service class.

param: string $serviceType Type of service (service key).
param: string $serviceSubType Sub type like file extensions or similar. Defined by the service.
param: mixed $excludeServiceKeys List of service keys which should be excluded in the search for a service. Array or comma list.
return: object The service object or an array with error info's.

requireOnce($requireFile)   X-Ref
Require a class for TYPO3
Useful to require classes from inside other classes (not global scope). A limited set of global variables are available (see function)

param: string $requireFile: Path of the file to be included
return: void

requireFile($requireFile)   X-Ref
Requires a class for TYPO3
Useful to require classes from inside other classes (not global scope).
A limited set of global variables are available (see function)

param: string $requireFile: Path of the file to be included
return: void

plainMailEncoded($email, $subject, $message, $headers = '', $encoding = 'quoted-printable', $charset = '', $dontEncodeHeader = FALSE)   X-Ref
Simple substitute for the PHP function mail() which allows you to specify encoding and character set
The fifth parameter ($encoding) will allow you to specify 'base64' encryption for the output (set $encoding=base64)
Further the output has the charset set to UTF-8 by default.

param: string $email Email address to send to. (see PHP function mail())
param: string $subject Subject line, non-encoded. (see PHP function mail())
param: string $message Message content, non-encoded. (see PHP function mail())
param: string $headers Headers, separated by LF
param: string $encoding Encoding type: "base64", "quoted-printable", "8bit". Default value is "quoted-printable".
param: string $charset Charset used in encoding-headers (only if $encoding is set to a valid value which produces such a header)
param: boolean $dontEncodeHeader If set, the header content will not be encoded.
return: boolean TRUE if mail was accepted for delivery, FALSE otherwise

quoted_printable($string, $maxlen = 76)   X-Ref
Implementation of quoted-printable encode.
See RFC 1521, section 5.1 Quoted-Printable Content-Transfer-Encoding

param: string $string Content to encode
param: integer $maxlen Length of the lines, default is 76
return: string The QP encoded string

encodeHeader($line, $enc = 'quoted-printable', $charset = 'utf-8')   X-Ref
Encode header lines
Email headers must be ASCII, therefore they will be encoded to quoted_printable (default) or base64.

param: string $line Content to encode
param: string $enc Encoding type: "base64" or "quoted-printable". Default value is "quoted-printable".
param: string $charset Charset used for encoding
return: string The encoded string

substUrlsInPlainText($message, $urlmode = '76', $index_script_url = '')   X-Ref
Takes a clear-text message body for a plain text email, finds all 'http://' links and if they are longer than 76 chars they are converted to a shorter URL with a hash parameter. The real parameter is stored in the database and the hash-parameter/URL will be redirected to the real parameter when the link is clicked.
This function is about preserving long links in messages.

param: string $message Message content
param: string $urlmode URL mode; "76" or "all"
param: string $index_script_url URL of index script (see makeRedirectUrl())
return: string Processed message content

makeRedirectUrl($inUrl, $l = 0, $index_script_url = '')   X-Ref
Sub-function for substUrlsInPlainText() above.

param: string $inUrl Input URL
param: integer $l URL string length limit
param: string $index_script_url URL of "index script" - the prefix of the "?RDCT=..." parameter. If not supplied it will default to t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php'
return: string Processed URL

freetypeDpiComp($font_size)   X-Ref
Function to compensate for FreeType2 96 dpi

param: integer $font_size Fontsize for freetype function call
return: integer Compensated fontsize based on $GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi']

initSysLog()   X-Ref
Initialize the system log.

return: void

sysLog($msg, $extKey, $severity = 0)   X-Ref
Logs message to the system log.
This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors.
If you want to implement the sysLog in your applications, simply add lines like:
t3lib_div::sysLog('[write message in English here]', 'extension_key', 'severity');

param: string $msg Message (in English).
param: string $extKey Extension key (from which extension you are calling the log) or "Core"
param: integer $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is error, 4 is fatal error
return: void

devLog($msg, $extKey, $severity = 0, $dataVar = FALSE)   X-Ref
Logs message to the development log.
This should be implemented around the source code, both frontend and backend, logging everything from the flow through an application, messages, results from comparisons to fatal errors.
The result is meant to make sense to developers during development or debugging of a site.
The idea is that this function is only a wrapper for external extensions which can set a hook which will be allowed to handle the logging of the information to any format they might wish and with any kind of filter they would like.
If you want to implement the devLog in your applications, simply add lines like:
if (TYPO3_DLOG)    t3lib_div::devLog('[write message in english here]', 'extension key');

param: string $msg Message (in english).
param: string $extKey Extension key (from which extension you are calling the log)
param: integer $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message
param: mixed $dataVar Additional data you want to pass to the logger.
return: void

deprecationLog($msg)   X-Ref
Writes a message to the deprecation log.

param: string $msg Message (in English).
return: void

getDeprecationLogFileName()   X-Ref
Gets the absolute path to the deprecation log file.

return: string absolute path to the deprecation log file

logDeprecatedFunction()   X-Ref
Logs a call to a deprecated function.
The log message will be taken from the annotation.

return: void

arrayToLogString(array $arr, $valueList = array()   X-Ref
Converts a one dimensional array to a one line string which can be used for logging or debugging output
Example: "loginType: FE; refInfo: Array; HTTP_HOST: www.example.org; REMOTE_ADDR: 192.168.1.5; REMOTE_HOST:; security_level:; showHiddenRecords: 0;"

param: array $arr Data array which should be outputted
param: mixed $valueList List of keys which should be listed in the output string. Pass a comma list or an array. An empty list outputs the whole array.
param: integer $valueLength Long string values are shortened to this length. Default: 20
return: string Output string with key names and their value as string

imageMagickCommand($command, $parameters, $path = '')   X-Ref
Compile the command for running ImageMagick/GraphicsMagick.

param: string $command Command to be run: identify, convert or combine/composite
param: string $parameters The parameters string
param: string $path Override the default path (e.g. used by the install tool)
return: string Compiled command that deals with IM6 & GraphicsMagick

unQuoteFilenames($parameters, $unQuote = FALSE)   X-Ref
Explode a string (normally a list of filenames) with whitespaces by considering quotes in that string. This is mostly needed by the imageMagickCommand function above.

param: string $parameters The whole parameters string
param: boolean $unQuote If set, the elements of the resulting array are unquoted.
return: array Exploded parameters

quoteJSvalue($value)   X-Ref
Quotes a string for usage as JS parameter.

param: string $value the string to encode, may be empty
return: string the encoded value already quoted (with single quotes),

cleanOutputBuffers()   X-Ref
Ends and cleans all output buffers

return: void

flushOutputBuffers()   X-Ref
Ends and flushes all output buffers

return: void