Helpers

Introduction

Exception provides native helpers and generic tools that lets you work with auth, texts, forms, dates, http requests and code.

You can access to them in every controller using $this->tool(), $this->auth(), $this->text(), $this->form(), $this->date() or $this->http() methods.

You can also use them everywhere within $app->tool(), $app->auth(), $app->text(), $app->form(), $app->date() or $app->http() but you have to get istance global $app;.

Auth helpers



$this->auth->passwordhash(SECRET PASS)

This function creates an encrypted password based on BCRYPT algorit and return it as a string.



$this->auth->passwordcheck(SECRET PASS, PASS HASH)

This function validates a BCRYPT encrypt password and return a TRUE or FALSE value.



$app->auth->passwordsecure(PASS)

This function checks if a password is secure or not and returns a TRUE or FALSE value.



$this->auth->tokengenerate()

This function creates an univoque token, puts it in "core_auth_token" server session and return it into a string.



$this->auth->tokenverify(INPUT TOKEN)

This function verify the input token with the "core_auth_token" session and return a TRUE or FALSE value. This function manages also "core_auth_session_token" and "core_auth_session_try".



$this->auth->otpgenerate()

This function creates a temporaney otp code, puts it into a "core_auth_otp" server session and return it as a string.



$this->auth->otpverify(INPUT OTP)

This function verify the input opt with the"core_auth_otp" and return TRUE or FALSE.



$this->auth->start(LEVEL)

This function start a login session and set an optional user level identify by a number putting all in 2 sessions: "core_auth_session" and "core_auth_level".



$this->auth->verify(LEVEL)

This function validates user session and user level (optional) returning a TRUE or FALSE value.



$this->auth->stop()

This function stops all user sessions.



$this->auth->level()

This function returns user level into a string.



$this->auth->try(VALUE NUMBER)

This function adds a VALUE NUMBER to user try session.



$this->auth->tryverify(MAX NUMBER)

This funcion verifies if max value of session try is equal to current user session try value and return TRUE or FALSE value.

Text helpers



$this->text->replace(TEXT, STRING, NEWSTRING)

This function replaces a STRING with a new STRING into a TEXT.



$this->text->length(STRING)

This function returns the length of a string.



$this->text->left(STRING, CHARS)

This function returns first CHARS of a STRING.



$this->text->right($string=NULL, $chars=NULL)

This function returns last CHARS of a STRING.



$this->text->lefttrim(STRING, CHARS)

This function trims first CHARS of a STRING.



$this->text->righttrim(STRING, CHARS)

This function trims last CHARS of a STRING.



$this->text->truncate(STRING, CHARS, END)

This function truncates a string at a CHARS n° of letters and appends an end (ex. ...).



$this->text->reverse(STRING)

This function returns a reversed STRING.



$this->text->uppercase(STRING)

This function returns an uppercase STRING.



$this->text->lowercase(STRING)

This function returns an lowercase STRING.



$this->text->capitalize(STRING, OPTION)

This function returns a capitalize STRING (opt. 0) or a full words capitalize STRING (opt. 1).



$this->text->wrap(STRING, CHARS, TAG)

This function inserts a TAG every CHARS in STRING.



$this->text->words(STRING)

This function counts words in STRING.



$this->text->brfromn(STRING)

This function returns STRING \ n into < br >.



$this->text->brton(STRING)

This function returns STRING < br > into \ n.



$this->text->slug(STRING, DELIMITER)

This function returns a SLUG from a STRING using a DELIMITER.



$this->text->utf8(STRING)

This function returns an UTF-8 string.

Form helpers



$this->form->clean(STRING)

This function cleans a STRING from dangerous charters.



$this->form->cleanlight(STRING)

This function cleans a STRING from dangerous charters (in light version).



$this->form->isurl(STRING)

This function verifies if a string is an URL and returns a TRUE or FALSE value.



$this->form->ismail(STRING)

This function verifies if a string is an E-MAIL and returns a TRUE or FALSE value.



$this->form->isnotempty(STRING)

This function verifies if a string is not empty and returns a TRUE or FALSE value.



$this->form->isanumber(STRING)

This function verifies if a string is a number and returns a TRUE or FALSE value.



$this->form->isinto(STRING, WORD)

This function verifies if in a STRING there is one (or more) WORD returning TRUE or FALSE value.



$this->form->ismin(STRING, LONG)

This function verifies if a STRING is minium LONG and returns TRUE or FALSE value.



$this->form->ismax(STRING, LONG)

This function verifies if a STRING is maxium LONG and returns TRUE or FALSE value.

Date helpers



$this->date->now()

This function returns current datetime in standard format as a string.



$this->date->convert(DATE, TO FORMAT, FROM FORMAT)

This function converts date format using PHP date() standard formats of a declared DATE, FROM a format TO a new format.



$this->days(DATE A, DATE B)

This function returns as a string the number of days beetweek two dates (better in Y-m-d format).



$this->change(DATE, REQUEST, FORMAT)

This function returns as a string a new date based on an original date and based on a request.

Http helpers



$this->http->to(METHOD, URL, DATA, HEADER)

This function sends DATA (array) to an URL with a custom HEADER (array) trough a METHOD.



$this->http->from(METHOD, IP)

This function receives data trasmitted to page in a determinated METHOD from an optional list of IP (array or string).



$this->http->response(CODE)

This function returns a custom CODE header.



$this->http->responseget(URL)

This function gets and returns an URL header.

Tool helpers



$this->tool->arraycombinations(ARRAYS)

This functions takes an array of arrays and combines them into a multi-array matrix.



$this->tool->arraynokey(ARRAY)

This function returns an ARRAY without the first level array keys.



$this->tool->isonline(URL)

This function checks if an URL is or not on-line and returns TRUE or FALSE value.



$this->tool->userip()

This function returns user IP address.



$app->tool->userlang()

This function returns user browser lang code.



$this->tool->redirect(URL)

This function redirects to an URL.



$this->tool->jsontoarray(JSON)

This function returns an array from a JSON.



$this->tool->jsonfromarray(ARRAY)

This function returns a JSON from an ARRAY.



$this->tool->sessionset(VARS)

This function adds an array of vars to session.



$this->tool->sessionread(VAR)

This function returns a VAR session value.



$this->tool->cookieset(NAME, VALUE, TIME)

This function sets a cookie with a NAME, a VALUE and a TIME in seconds.



$this->tool->cookieread(NAME)

This function returns a cookie value.



$this->tool->encrypt(STRING, KEY)

This function encrypts a STRING with a KEY.



$this->tool->decrypt(STRING, KEY)

This function decrypts a STRING with a KEY.



$this->tool->password(LENGHT)

This function returns a LENGHT password.



$this->tool->code(LENGHT)

This function returns a LENGHT code.



$this->tool->coden(LENGHT)

This function returns a LENGHT numeric code.



$this->tool->codean(LENGHT)

This function returns a LENGHT alfanumeric code.



$this->tool->unique()

This function returns an unique code.



$this->tool->string()

This function returns an unique string.



$this->tool->xls(ITEMS, HEADER, FILENAME)

This function generates a file excel using an array of ITEMS (rows and cols) with an HEADER (titles) and automatically generates a file with a custom FILENAME (optional)



$this->tool->csv(ITEMS, FILENAME)

This function generates a file CSV using an array of ITEMS (rows and cols) and automatically generates a file with a custom FILENAME (optional)

Do you need help?

Write me an e-mail: [email protected]