Download the PHP package supergnaw/form-security without Composer
On this page you can find all versions of the php package supergnaw/form-security. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download supergnaw/form-security
More information about supergnaw/form-security
Files in supergnaw/form-security
Package form-security
Short Description Class for simplifying webpage form security
License AGPL-3.0
Informations about the package form-security
FormSecurity
PHP class for simplifying webpage form security. The main purpose for the creation of this class was to help mitigate against CSRF. The class can validate the following types of inputs:
- boolean
- numeric
- float
- integer
- hexadecimal integer
- octal integer
- network
- ipv4
- ipv6
- mac address
- timestamp
- date
- time
- timestamp
- string
- alphanumeric
- hexadecimal
- encoded html
- url
- string
Token
Form Tokens
FormSecurity can generate nonce tokens to be used to verify a form can only be submitted once. To use the token, simply generate a token, add it to a hidden form input, then validate the submitted token against the one saved in the session variable.
Generate the token
Store the generated token in a form hidden input
Validate the submitted token
Clearing All Tokens
If for whatever reason you need to clear any saved tokens, use token_clear_all()
.
Whitelist & Blacklist
FormSecurity can apply a whitelist or blacklist to a given input and filter out unwanted or unexpected inputs.
Filter
FormSecurity can filter the values of a given input (get
, post
, cookie
, server
, or env
) and remove any values
that do not match their expected type (bool
, float
, hexint
, int
, octint
, ipv4
, ipv6
, mac
, date
, time
, timestamp
, string
, alnum
, url
, email
, or htmlenc
).
Granular Filtering
FormSecurity filters can also be used individually to validate individual inputs, where null
will be returned on any
failure.
FormSecurity::filter_boolean()
FormSecurity::filter_float()
FormSecurity::filter_int()
FormSecurity::filter_hexint()
FormSecurity::filter_octint()
FormSecurity::filter_ipv4()
FormSecurity::filter_ipv6()
FormSecurity::filter_mac()
FormSecurity::filter_string()
FormSecurity::filter_alnum()
FormSecurity::filter_hex()
FormSecurity::filter_url()
FormSecurity::filter_email()
FormSecurity::filter_htmlenc()
FormSecurity::filter_date()
FormSecurity::filter_time()
FormSecurity::filter_timestamp()
String Cleaning
FormSecurity can clean strings