V2:Configuration

From PhpInputValidator

Jump to: navigation, search

The phpInputValidator has v2:Default configuration settings that will be setup when no values override them. So if you do not want to configure the system you don't have to.

Contents

How to configure

To configure phpInputValidator you need to pass an array of configuration values to the constructor when creating a new instance of the class. Here is an example:

$config = array('date_format' => 'D, d M Y H:i', 'language' => 'en_us');
$getvar = new phpInputValidator($config);

Configuration options

add_slashes_function (string)

A function to run to add slashes to data. By default the php function addslashes is run to add slashes to a string.

However it is generally better to run a DB specific function for adding slashes. A couple of examples of better functions to use might be mysqli_real_escape_string or mysql_real_escape_string. Which you can use by using this configuration option.

Example

$config = array('add_slashes_function' => 'mysqli_real_escape_string');

append_unset (array)

Allows to append global variables to not unset if the unset global function is run

Example

$config = array('append_unset' => array('foo' => true, 'glob' => true));

date_format (string)

This is the formatting you wish to apply to the date and time on logged events. The string needs to follow the php date function formatting. An example: 'D, d M Y H:i'

Example

$config = array('date_format' => 'D, d M Y H:i');

error_log (string)

This is the name you wish to give the error log

Example

$config = array('error_log' => 'errors.log');

html_purifier_config (array of strings)

Any configuration you want to use with HTMLPurifier. You must have HTMLPurifier installed and a valid html_purifier_path to use this option. See the HTMLPurifier configuration docs for more information.

Example

$config = array('html_purifier_config' => array(
        'HTML' => array('TidyLevel' => 'heavy', 'Doctype' => 'XHTML 1.0 Transitional'),
        'Core' => array('EscapeNonASCIICharacters' => true),
););

html_purifier_path (string)

The absolute path to the location of HTMLPurifier.

Example

$config = array('html_purifier_path' => dirname(__FILE__).'/htmlpurifier/');

language (string)

The language file to load.

Example

$config = array('language' => 'en_us');

log_path (string)

The absolute path to the location to put log files.

Example

$config = array('log_path' => dirname(__FILE__).'/logs/');

security (array)

See Security Configuration

unset_globals (bool)

Run the unset variables function.

Example

$config = array('unset_globals' => true);