PHP Класс defender, PHP-Fusion

| https://www.php-fusion.co.uk/ +--------------------------------------------------------+ | Filename: defender.inc.php | Author : Frederick MC Chan (Hien) | Co-Author: Dan C (JoiNNN) | Version : 9.0.5 (please update every commit) +--------------------------------------------------------+ | This program is released as free software under the | Affero GPL license. You can redistribute it and/or | modify it under the terms of this license which you | can read by viewing the included agpl.txt or online | at www.gnu.org/licenses/agpl.html. Removal of this | copyright header is strictly prohibited without | written permission from the original author(s). +--------------------------------------------------------
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$debug
$error_title
$field Declared by Form Sanitizer
$field_config
$field_default
$field_name
$field_value
$input_errors
$ref

Открытые методы

Метод Описание
add_field_session ( array $array )
form_sanitizer ( $value, $default = "", $input_name = FALSE, $is_multiLang = FALSE ) need to register the file.
generate_token ( $form_id = 'phpfusion', $max_tokens = 10, $file = "" )
getErrorText ( $input_name ) Fetches the latest error text of this input Important! Ensure your applications do not refresh screen for this error to show.
getInputErrors ( ) : array
get_current_field_session ( string $input_name = "" ) : string Return the current document field session or sessions Use for debug purposes
inputHasError ( $input_name )
pageHash ( $file = "" ) : string Generates a md5 hash of the current page to make token session unique Eg. /php-fusion/infusions/blog/blog.php for Non
remove_token ( )
safe ( ) : boolean Request whether safe to proceed at all times
sanitize_array ( $array )
setErrorText ( $input_name, $text ) Set and override default field error text
setInputError ( $input_name )
set_sessionUserID ( ) : mixed ID for Session No $userName because it can be changed and tampered via Edit Profile.
sniff_token ( ) Token Sniffer Checks whether a post contains a valid token
stop ( ) Send an Unsafe Signal acorss all PHP-Fusion Components This will automatically halt on all important execution without exiting.
unset_field_session ( ) Marks an input as invalid
validate ( )

Защищенные методы

Метод Описание
verify_checkbox ( ) Validate a checkbox If field Value is multiple checkbox, post value must be an array If field value is a radio, post value must not be an array If field value is a number, post value must be a boolean 1 or 0
verify_date ( ) : integer | string Check and verify submitted date If type is timestamp, it will return a Unix timestamp If type is date, it will return a date
verify_email ( ) Checks if is a valid email address accepts only 50 characters + @ + 4 characters returns str the input or bool FALSE if check fails
verify_file_upload ( )
verify_image_upload ( )
verify_number ( ) Checks if is a valid number returns str the input or bool FALSE if check fails TODO: support decimal
verify_password ( ) Checks if is a valid password accepts minimum of 8 and maximum of 64 due to encrypt limit returns str the input or bool FALSE if check fails
verify_text ( ) validate and sanitize a text accepts only 50 characters + @ + 4 characters returns str the sanitized input or bool FALSE if safemode is set and the check fails
verify_url ( ) Checks if is a valid URL require path.

Приватные методы

Метод Описание
verify_token ( integer $post_time = 5 ) : boolean Plain Token Validation - executed at maincore.php through sniff_token() only.

Описание методов

add_field_session() статический публичный Метод

static public add_field_session ( array $array )
$array array

form_sanitizer() публичный Метод

need to register the file.
public form_sanitizer ( $value, $default = "", $input_name = FALSE, $is_multiLang = FALSE )

generate_token() публичный Метод

public generate_token ( $form_id = 'phpfusion', $max_tokens = 10, $file = "" )

getErrorText() публичный Метод

Use $defender->safe() or \defender::safe(); for conditional redirect.
public getErrorText ( $input_name )
$input_name

getInputErrors() публичный Метод

public getInputErrors ( ) : array
Результат array

get_current_field_session() статический публичный Метод

Return the current document field session or sessions Use for debug purposes
static public get_current_field_session ( string $input_name = "" ) : string
$input_name string
Результат string

inputHasError() публичный Метод

public inputHasError ( $input_name )

pageHash() публичный статический Метод

Generates a md5 hash of the current page to make token session unique Eg. /php-fusion/infusions/blog/blog.php for Non
public static pageHash ( $file = "" ) : string
Результат string

remove_token() публичный Метод

public remove_token ( )

safe() публичный статический Метод

Request whether safe to proceed at all times
public static safe ( ) : boolean
Результат boolean

sanitize_array() статический публичный Метод

static public sanitize_array ( $array )

setErrorText() публичный Метод

Set and override default field error text
public setErrorText ( $input_name, $text )
$input_name
$text

setInputError() публичный Метод

public setInputError ( $input_name )

set_sessionUserID() статический публичный Метод

Using IP address extends for guest
static public set_sessionUserID ( ) : mixed
Результат mixed

sniff_token() публичный Метод

Token Sniffer Checks whether a post contains a valid token
public sniff_token ( )

stop() статический публичный Метод

Send an Unsafe Signal acorss all PHP-Fusion Components This will automatically halt on all important execution without exiting.
static public stop ( )

unset_field_session() публичный статический Метод

Marks an input as invalid
public static unset_field_session ( )

validate() публичный Метод

public validate ( )

verify_checkbox() защищенный Метод

Validate a checkbox If field Value is multiple checkbox, post value must be an array If field value is a radio, post value must not be an array If field value is a number, post value must be a boolean 1 or 0
protected verify_checkbox ( )

verify_date() защищенный Метод

Check and verify submitted date If type is timestamp, it will return a Unix timestamp If type is date, it will return a date
protected verify_date ( ) : integer | string
Результат integer | string

verify_email() защищенный Метод

Checks if is a valid email address accepts only 50 characters + @ + 4 characters returns str the input or bool FALSE if check fails
protected verify_email ( )

verify_file_upload() защищенный Метод

protected verify_file_upload ( )

verify_image_upload() защищенный Метод

protected verify_image_upload ( )

verify_number() защищенный Метод

Checks if is a valid number returns str the input or bool FALSE if check fails TODO: support decimal
protected verify_number ( )

verify_password() защищенный Метод

Checks if is a valid password accepts minimum of 8 and maximum of 64 due to encrypt limit returns str the input or bool FALSE if check fails
protected verify_password ( )

verify_text() защищенный Метод

validate and sanitize a text accepts only 50 characters + @ + 4 characters returns str the sanitized input or bool FALSE if safemode is set and the check fails
protected verify_text ( )

verify_url() защищенный Метод

returns str the input or bool FALSE if check fails
protected verify_url ( )

Описание свойств

$debug публичное свойство

public $debug

$error_title публичное свойство

public $error_title

$field публичное свойство

Declared by Form Sanitizer
public $field

$field_config публичное свойство

public $field_config

$field_default публичное свойство

public $field_default

$field_name публичное свойство

public $field_name

$field_value публичное свойство

public $field_value

$input_errors публичное свойство

public $input_errors

$ref публичное свойство

public $ref