>> YANA 4 PHP Framework >> Docs for page toolbox.php

/includes/toolbox.php

Description

Common tools

This file contains a variety of tools that might be usefull to all applications, no matter wether the use the rest of the framework or not.

Functions

Lowercase or uppercase all keys of an associative array
array changeCaseArray (
mixed $input, [int|bool $case = CASE_LOWER], array $A
)
List of parameters:
Name Type Description
$A array
$case int|bool CASE_UPPER or CASE_LOWER
Description:

This is a recursive implementation of the PHP function array_change_key_case(). It takes the same arguments: an array $input to work on and an optional argument $case. The argument $case can be one of two constants: CASE_LOWER and CASE_UPPER, where CASE_LOWER is the default.

recursive deep-copy on arrays
array cloneArray (
array $array
)
List of parameters:
Name Type Description
$array array
Description:

This function creates a deep-copy of the input $array and returns it.

"Deep-copy" means, it tries to clone objects registered in the array by calling the function "copy()", if the object has any, or by using the keyword "clone" as of PHP 5.

Note that this will not work correctly, if the object has neither the one nor the other.

  • since: 2.8.5
list contents of a directory
array dirlist (
string $dir, [string $filter = ""], [mixed $switch = 0]
)
List of parameters:
Name Type Description
$dir string
$filter string
Description:

The argument $filter may contain multiple file extension, use a pipe '|' sign to seperate them. Example: "*.xml|*.html" will find all xml- and html-files

recursively merge two arrays to one
array mergeArrays (
array $A, array $B
)
List of parameters:
Name Type Description
$A array
$B array
Description:

This function is pretty much the same as the php function "array_merge_recursive" except for the way how duplicate keys are treated. Dupplicate keys get replaced in this implementation rather than being appended.

Untaint user input taken from a web form
mixed untaintInput (
mixed $value, [string $type = ""], [int $length = 0], [int $escape = 0]
)
List of parameters:
Name Type Description
$value mixed the input data
$type string desired type, note that this should always be a scalar type
$length int maximum length (as number of characters!), note that a float of 10.3 and length 3 will convert to 10., NOT 10.3!
$escape int choose how special characters should be treated
Description:

This function scrubbs your user input data shiny and clean.

It ensures: the data has a given type, maximum length, and syntax. E.g. if the data comes out of an input-field use this function with the argument $escape set to YANA_ESCAPE_LINEBREAK, to enforce the input does not have any unexpected line breaks.

Valid values for parameter $type:

  • int, integer
  • float, double
  • boolean, bool
  • string
  • object
  • time = the input is an unix time code
  • mail = the input is a mail adress
  • ip = the input is an IP adress
  • select = the input is taken from a select field (treated as "string")
  • text = the input is taken from a textarea field (treated as "string")

Valid values for parameter $escape:

  • YANA_ESCAPE_NONE = leave special chars alone (default)
  • YANA_ESCAPE_SLASHED = apply addslashes()
  • YANA_ESCAPE_TOKEN = replace template delimiters with html-entities
  • YANA_ESCAPE_CODED = convert all characters to html-entities
  • YANA_ESCAPE_LINEBREAK = revert all white-space to spaces
    (for security reasons you should ALWAYS use this setting if you
    expect data from any other field than textarea)
  • YANA_ESCAPE_USERTEXT = treat full-text message from an textarea element,
    prevents flooding by removing doubled elements

  • uses: $saveInput - = untaintInput($_GET['message'], 'string', 1024, YANA_ESCAPE_USERTEXT)

Documentation generated on Fri, 10 Nov 2006 00:35:58 +0100 by phpDocumentor 1.3.0RC4

yana author: Thomas MeyerHomepage: www.all-community.de/pub