FileAccess Orion

Sanitize
in package

Implement sanitize handler

This class provides interfaces for input validation handling. Use it to clean user input to prevent injections or other bad contents from being stored.

Tags
category

Kernel

author

Tobias Teichner webmaster@teichner.biz

since

File available since v0.40

Table of Contents

$purifier  : HTMLPurifier|null
The html purify framework instance
AsciiToken()  : string
clear a text field with letters cleanup not formatted text using restrictive mode
AttributeToInterval()  : DateInterval|float|int|null
System interval unit to date interval or, seconds
CleanSolrSearch()  : mixed
Escape search server (Solr) string
ClearMail()  : string
Replace the @ symbol
ClearPhone()  : string
Clear phone number
DataStorageFolder()  : bool|string
Clear a path
Email()  : string|bool
filter possible email address cleanup path string and make sure its only valid email address content inside
FileName()  : string|bool
clear a path cleanup path string and make sure it is has no evil letters
Html()  : string
Clear a html field with letters
HtmlPurifyAvailable()  : bool
Check if lib available
IsoDate()  : string|null
Create iso date from utf date
IsValidIBAN()  : bool
Validation function
RelativeFileName()  : string
clear a relative path cleanup path string and make sure it is has no evil letters
RoundedTime()  : float|int
SubstringAfter()  : string
Return substring after certain string
TimeToLocal()  : null|string|DateTime
Local time
UnFormattedText()  : string
Clear a text field with letters

Properties

$purifier

The html purify framework instance

private static HTMLPurifier|null $purifier = null

The instance

Methods

AsciiToken()

clear a text field with letters cleanup not formatted text using restrictive mode

public static AsciiToken(string $text[, bool $clear = false ]) : string
Parameters
$text : string

A insecure string

$clear : bool = false

When true remove potentially problematic characters

Return values
string

The sanitized ascii letter string

AttributeToInterval()

System interval unit to date interval or, seconds

public static AttributeToInterval(array<string|int, mixed> $val[, string $format = 'seconds' ][, float|int $factor = 1 ]) : DateInterval|float|int|null
Parameters
$val : array<string|int, mixed>

The interval

$format : string = 'seconds'

The target format, seconds or native

$factor : float|int = 1

The factor to add

Return values
DateInterval|float|int|null

CleanSolrSearch()

Escape search server (Solr) string

public static CleanSolrSearch(string|float|int $str) : mixed

Escapes all control characters that are potentially used by Solr server

Parameters
$str : string|float|int

The string to escape, ma be a number

Return values
mixed

The escaped string

ClearMail()

Replace the @ symbol

public static ClearMail(string $num) : string
Parameters
$num : string
Return values
string

ClearPhone()

Clear phone number

public static ClearPhone(string $num) : string
Parameters
$num : string
Return values
string

DataStorageFolder()

Clear a path

public static DataStorageFolder(string $path[, string $base_path = FAA_PATHS_DATA_REAL ]) : bool|string

Cleanup path string and make sure it is located inside the data storage

Parameters
$path : string

A possible folder or file path

$base_path : string = FAA_PATHS_DATA_REAL

Must be in this folder

Return values
bool|string

The sanitized path or false when matching failed

Email()

filter possible email address cleanup path string and make sure its only valid email address content inside

public static Email(string $string) : string|bool
Parameters
$string : string

A possible email address

Return values
string|bool

The sanitized email address or false when matching failed

FileName()

clear a path cleanup path string and make sure it is has no evil letters

public static FileName(string $text[, bool $clear = false ]) : string|bool
Parameters
$text : string

A possible folder or file path

$clear : bool = false

When true remove potentially problematic characters

Return values
string|bool

The sanitized path or false when matching failed

Html()

Clear a html field with letters

public static Html(string $string) : string

Cleanup formatted html using html purifier, will recreate the whole html content that was given as argument

Parameters
$string : string

An insecure string

Return values
string

The sanitized utf8 html string

HtmlPurifyAvailable()

Check if lib available

public static HtmlPurifyAvailable() : bool

Test if the HTML purify library is available

Return values
bool

IsoDate()

Create iso date from utf date

public static IsoDate([string $date = 'now' ]) : string|null
Parameters
$date : string = 'now'
Return values
string|null

RelativeFileName()

clear a relative path cleanup path string and make sure it is has no evil letters

public static RelativeFileName(string|null $text[, bool $clear = false ]) : string
Parameters
$text : string|null

A possible folder or file path

$clear : bool = false

When true remove potentially problematic characters

Return values
string

The sanitized path or false when matching failed

RoundedTime()

public static RoundedTime(bool $lower[, null $seconds = null ][, int $offset = 15 ]) : float|int
Parameters
$lower : bool
$seconds : null = null
$offset : int = 15
Tags
deprecated
Return values
float|int

SubstringAfter()

Return substring after certain string

public static SubstringAfter(string $string, string $needle, int $offset) : string
Parameters
$string : string
$needle : string
$offset : int
Return values
string

TimeToLocal()

Local time

public static TimeToLocal(string|int $date[, string|null $time_zone = FAA_TIMEZONE ][, string|null $format = 'Y-m-d H:i:s T' ]) : null|string|DateTime

Convert a UTC time to local time and return it formatted based on the given value

Parameters
$date : string|int

The UTC source date

$time_zone : string|null = FAA_TIMEZONE

The time zone e.g. Europe/Berlin

$format : string|null = 'Y-m-d H:i:s T'

The target format

Return values
null|string|DateTime

The formatted date in the locale time zone

UnFormattedText()

Clear a text field with letters

public static UnFormattedText(string|null $text[, bool $clear = false ]) : string

Cleanup not formatted text and remove invalid or potentially harming characters

Parameters
$text : string|null

A insecure string

$clear : bool = false

When true remove potentially problematic characters

Return values
string

The sanitized utf8 string

Search results