Once you start building applications, you will add PHP code to events. Below is a list of pre-set functions you can use

arrayToStringConverts an array into a string, sanitizing the individual rowsfunction arrayToString($array)stringthis funciton uses the htmlspecialchars to sanitize strings.
checkClientIpVerifies that the IP of the request is in line with the current sessionfunction checkClientIp()true/falseReturns false when the used IP is different then the previous transaction within that same session
clean_htmlClean 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 HTMLbased upon
cleanClean string from all cr/lf pairsfunction clean($text)string
closeSessionCloses the session by unsetting it, destroying it, closes the write buffer and clears the session cookie.function closeSession()nothing
dblogAppends 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.
downloadDownload a filefunction download($path, $file)
encryptpswEncrypts the password with the given method (none, md5, sha, php)function encryptpsw($passwrd, $method)password
extractFieldNameExtract the fieldname of a table.field pairfunction extractFieldName($theField)field name
getGUIDRetrieves a unique stringfunction getGUID()stringReturns 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.
getHTMLColorsRetrieves an array of html colorsfunction getHTMLColors()html colors
get_ip_addressReturns the ip of the current userfunction get_ip_address()ip address
getProtocolReturns the used protocol as HTTP: or HTTPS: function getProtocol()HTTP: or HTTPS:
inPostStateTests if the form has received form data or is in it's initials statefunction inPostState();true, falseif(inPostState() ){…}
isAjax()Tests if the form is called in ajax modefunction isAjax()true,falseif(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.
isHTTPSVerifies if the application runs under httpsfunction isHTTPS()true, false
isLoggedOnTest if the application has the 'logged-on' statusfunction isLoggedOn()true,false
isTrueTest if a value is truefunction toClass($strin)true, falseChecks for all kind of values: t, T, y, Y, true, TRUE, yes, YES
getExternalSessionVarGet a session var of another modulefunction getExternalSessionVar($theVar, $default=,$origin=
phspCreateLinkCreate a valid link with an encrypted parameter list (including session variables)function phspCreateLink($url, $parms, $initialformmode='')linkThis 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.
phspCryptEncrypts or decrypts a string using the preset encryption parameters. funciton phspCrypt($strin, $action)encrypted stringUse '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.
phspRedirectRedirects 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.
phspExitBreaks current process and jumps to the given urlfunction phspExit($url)
rtrActionRetrieves 'action' from $_GET/$_POSTfunction rtrAction(); used internally
rtrCmdRetrieves 'cmd' from $_GET/$_POSTfunction rtrCmd(); used internally
rtrFormRetrieves 'frm' from $_GET/$_POSTfunction rtrFrm(); used internally
rtrGetVarRetrieves variable from $_GET/$_POSTfunction rtrGetVar($var)valueCan 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(….).
rtrQueryStringRetrieves query string from $_SERVERfunction rtrQueryString
rtrSenderRetrieves component sender from $_GET/$_POSTfunction rtrSender() Used to identify the component that is responsible for the submit/ajax trigger
rtrSubmitBtnRetrieves 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.
setLoggedOffSet application in 'logged-off' statusfunction setLoggedOff()
setLoggedOnSet application in 'logged-on' status for the given userid.function setLoggedOn($usernum='generic')
setSessionVarSets a session variablefunction setSessionVar($theVar, $value)nothingThis function sets a session variable that is maintained over the same session.
showMessageDisplays a modal messagefunction showMessage($msg)nothingIn 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.

Example: $app→showMessage('process complete');

See also macro notation (@@showMessage('…');
session_stopTerminates a sessionsession_stop()
sessionVarExists sessionVarExists($theVar)true,false
setFormMode($mode)Set next form mode to edit, delete, update, createsetFormMode($mode) Use this funciton before redirecting to the required module
setSessionVarSets a session variablefunction setSessionVar($theVar, $value)nothingThis function sets a session variable that is maintained over the same session.
unsetSessionVarUnsets a session variableunsetSessionVar($theVar)
toClassConverts a table.field name into a table_field name classtoClass($strin). → _
findComponentsearch component reference on component namefindComponentByName($theCompName)component reference or falseTraverses the component tree to find the required component
loginwrapper around the root component to loginlogin($uid, $pwd)true/false
logoffwrapper around the root component to logofflogoff()true/false
redirectredirect to the given urlRedirect($theUrl, $origin, $parms=,$initialformmode) Can be used in a regular status and within an ajax event. Origin: current module as recepient, parms: a=b&c=d&… parameter pairs, initialformmode: the form mode to start the next application in (insert, edit, delete, none) The parameter string will be encrypted using the project settings for security.
showMessageSets a session variableshowMessage($theMsg)nothingThis function sets a session variable that is maintained over the same session.
@@login(…)will be translated to $app→login(…) For some commonly used functions, it is more convenient to use the @@ notation as PHsPeed will 'know' in what module the function resides. So you don't have to remember that login is part of the $app.
@@showMessagewill be translated to $app>showMessage(…)
  • functions.txt
  • Last modified: 2021/08/29 18:30
  • by aducomadmin