Generic functions
Generic functions.
These functions can be accessed directly and are always available.
function |
description |
prototype |
returns |
Notes |
arrayToString |
Converts an array into a string, sanitizing the individual rows |
function arrayToString($array) |
string |
this funciton uses the htmlspecialchars to sanitize strings. |
checkClientIp |
Verifies that the IP of the request is in line with the current session |
function checkClientIp() |
true/false |
Returns false when the used IP is different then the previous transaction within that same session |
clean_html |
Clean HTML string removing all element attributes and elements which are not in the provided whitelist (but keeping their allowed children). |
function clean_html($html, array $whitelist) |
sanitized HTML |
based upon https://github.com/alixaxel/phunction/blob/master/phunction/HTML.php |
clean |
Clean string from all cr/lf pairs |
function clean($text) |
string |
|
closeSession |
Closes the session by unsetting it, destroying it, closes the write buffer and clears the session cookie. |
function closeSession() |
nothing |
|
dblog |
Appends a record to the personal logfile. |
function dblog($msg) |
|
This will append a record to the personal logfile that is created in the workarea. (dbg_'date'). This statement will NOT be removed when you promote your application for production and is the best way if you need to do some additional debugging and/or loggin while your application runs in the production environment. |
download |
Download a file |
function download($path, $file) |
|
|
encryptpsw |
Encrypts the password with the given method (none, md5, sha, php) |
function encryptpsw($passwrd, $method) |
password |
|
extractFieldName |
Extract the fieldname of a table.field pair |
function extractFieldName($theField) |
field name |
|
getGUID |
Retrieves a unique string |
function getGUID() |
string |
Returns a string that can be used for validation situations, i.e. for confirming credentials etc. In PHsPeed this string is used to let users validate their account. |
getHTMLColors |
Retrieves an array of html colors |
function getHTMLColors() |
html colors |
|
get_ip_address |
Returns the ip of the current user |
function get_ip_address() |
ip address |
|
getProtocol |
Returns the used protocol as HTTP: or HTTPS: |
function getProtocol() |
HTTP: or HTTPS: |
|
inPostState |
Tests if the form has received form data or is in it's initials state |
function inPostState(); |
true, false |
if(inPostState() ){…} |
isAjax() |
Tests if the form is called in ajax mode |
function isAjax() |
true,false |
if(isAjax()) {…} As the controller application is called in stages, the ajax stage is when the system needs to supply the form data. The initial stage is used to create the html template. To avoid operations being performed twice, you can use this switch to determine if your code needs to be executed in the initial or ajax state. |
isHTTPS |
Verifies if the application runs under https |
function isHTTPS() |
true, false |
|
isLoggedOn |
Test if the application has the 'logged-on' status |
function isLoggedOn() |
true,false |
|
isTrue |
Test if a value is true |
function toClass($strin) |
true, false |
Checks for all kind of values: t, T, y, Y, true, TRUE, yes, YES |
getExternalSessionVar |
Get a session var of another module |
function getExternalSessionVar($theVar, $default=,$origin= |
|
|
phspCreateLink |
Create a valid link with an encrypted parameter list (including session variables) |
function phspCreateLink($url, $parms, $initialformmode='') |
link |
This function returns a valid link that can be used as a valid hyperlink to any PHsPeed module. It encrypts the parameters to avoid security issues, and applies session info as well to avoid csrf issues. The parameters need to be applied in a=b pairs. The initial form mode specifies the state the form must open. Valid options are add, delete, update. |
phspCrypt |
Encrypts or decrypts a string using the preset encryption parameters. |
funciton phspCrypt($strin, $action) |
encrypted string |
Use 'e' to encrypt or 'd' to decrypt. The function will use AES-256-CBC as the encryption method and SHA256 as hash and thus performs a strong encryption that is reversable. |
phspRedirect |
Redirects the current page to the given url. |
function phspRedirect($url, $origin, $initialformmode) |
|
This function takes an url and jumps to that url. It will append security tokens. The $initialmode can be used to set the receiving application in a certain mode (none, init, add, edit, delete). This function cannot be used when executed in an ajax event. Use the $app→redirect for that purpose. |
phspExit |
Breaks current process and jumps to the given url |
function phspExit($url) |
|
|
rtrAction |
Retrieves 'action' from $_GET/$_POST |
function rtrAction(); |
|
used internally |
rtrCmd |
Retrieves 'cmd' from $_GET/$_POST |
function rtrCmd(); |
|
used internally |
rtrForm |
Retrieves 'frm' from $_GET/$_POST |
function rtrFrm(); |
|
used internally |
rtrGetVar |
Retrieves variable from $_GET/$_POST |
function rtrGetVar($var) |
value |
Can return variable and array. It also performs sanitizing. Use this function if you want to retrieve info from your application input instead of $_GET(…) or $_POST(….). |
rtrQueryString |
Retrieves query string from $_SERVER |
function rtrQueryString |
|
|
rtrSender |
Retrieves component sender from $_GET/$_POST |
function rtrSender() |
|
Used to identify the component that is responsible for the submit/ajax trigger |
rtrSubmitBtn |
Retrieves identifier of button that triggered the submit |
|
|
Used to find the button that is clicked. Useful when there are more submit buttons. This is an old method, consider using the appropiate submit event that returns the key automatically. |
setLoggedOff |
Set application in 'logged-off' status |
function setLoggedOff() |
|
|
setLoggedOn |
Set application in 'logged-on' status for the given userid. |
function setLoggedOn($usernum='generic') |
|
|
setSessionVar |
Sets a session variable |
function setSessionVar($theVar, $value) |
nothing |
This function sets a session variable that is maintained over the same session. |
showMessage |
Displays a modal message |
function showMessage($msg) |
nothing |
In general this function can be used to submit and in ajax stage to display a popup message, but only on events that passes the $app object. |
session_stop |
Terminates a session |
session_stop() |
|
|
sessionVarExists |
|
sessionVarExists($theVar) |
true,false |
|
setFormMode($mode) |
Set next form mode to edit, delete, update, create |
setFormMode($mode) |
|
Use this funciton before redirecting to the required module |
setSessionVar |
Sets a session variable |
function setSessionVar($theVar, $value) |
nothing |
This function sets a session variable that is maintained over the same session. |
unsetSessionVar |
Unsets a session variable |
unsetSessionVar($theVar) |
|
|
toClass |
Converts a table.field name into a table_field name class |
toClass($strin) |
. → _ |
|