>> 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.

  • licence: http://creativecommons.org/licenses/by-nc-sa/2.5/

Functions

changeCaseArray
array changeCaseArray (mixed $input, [int|bool $case = CASE_LOWER], array $A)

Lowercase or uppercase all keys of an associative array

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.

Name Type Description
$A array
$case int|bool CASE_UPPER or CASE_LOWER
dirlist
void dirlist (string $dir, [string $filter = ""], return 2)

list contents of a directory

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

Name Type Description
$dir string
$filter string
2 return array
mergeArrays
array mergeArrays (array $A, array $B)

recursively merge two arrays to one

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.

Name Type Description
$A array
$B array
untaintInput
mixed untaintInput (mixed $value, [string $type = ""], [int $length = 0], [int $escape = 0])

Untaint user input taken from a web form

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)
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

Documentation generated on Sat, 16 Sep 2006 17:06:16 +0200 by phpDocumentor 1.3.0RC4

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