LimeSurvey API - Master branch

common_helper.php

Table of Contents

Functions

gT()  : string
Returns $sToTranslate translated to $sLanguage (defaults to lang set in session) escaped with $sEscapeMode
eT()  : void
As gT(), but echoes directly
ngT()  : string
Translation helper function for plural forms
neT()  : mixed
Translation helper function for plural forms which outputs right away
quoteText()  : mixed|string
Quotes a translation according to purpose if sEscapeMode is null, we use HTML method because probably we had to specify null as sEscapeMode upstream
getSurveyList()  : string|array<string|int, mixed>
getSurveyList() Queries the database (survey table) for a list of existing surveys
getGidPrevious()  : int|string
getGidPrevious() returns the Gid of the group prior to the current active group
getGidNext()  : int|string
getGidNext() returns the Gid of the group next to the current active group
convertGETtoPOST()  : string
convertGETtoPOST a function to create a post Request from get parameters !!! This functions result has to be wrappen in singlequotes!
calculateTotalFileUploadUsage()  : mixed
This function calculates how much space is actually used by all files uploaded using the File Upload question type
getDirectorySize()  : int
getMaxGroupOrder()  : int
Queries the database for the maximum sortorder of a group and returns the next higher one.
getGroupOrder()  : int
Queries the database for the sortorder of a group.
getMaxQuestionOrder()  : int
Queries the database for the maximum sort order of questions inside question group.
setupColumns()  : array<string|int, mixed>
setupColumns() defines all the html tags to be wrapped around various list type answers.
alternation()  : mixed
longestString()  : int
longestString() returns the length of the longest string past to it.
getGroupList3()  : mixed
getGroupListLang()  : string
put your comment there.
getUserList()  : array<string|int, mixed>
Returns a user list. If 'usercontrolSameGroupPolicy' is set and set to true, only users which are in the same group as me (--> logged in user) will be returned. Superadmin always gets the full list of users.
getSurveyInfo()  : array<string|int, mixed>|bool
Gets all survey infos in one big array including the language specific settings
templateDefaultTexts()  : array<string|int, mixed>
Returns the default email template texts as array
groupOrderThenQuestionOrder()  : int
Compares two elements from an array (passed by the usort function) and returns -1, 0 or 1 depending on the result of the comparison of the sort order of the group_order and question_order field Used by : - remotecontrol_handle->export_statistics with merging group and question attributes (all in same array) - checkQuestions() in activate_helper function with ?
fixMovedQuestionConditions()  : mixed
returnGlobal()  : array<string|int, mixed>|bool|mixed|int|null
This function returns POST/REQUEST vars, for some vars like SID and others they are also sanitized TODO: extends Yii:getParam
sendCacheHeaders()  : mixed
getExtendedAnswer()  : string
validateEmailAddress()  : mixed
Validate an email address - also supports IDN email addresses
validateEmailAddresses()  : string
Validate an list of email addresses - either as array or as semicolon-limited text
createCompleteSGQA()  : array<string|int, mixed>
This functions generates a a summary containing the SGQA for questions of a survey, enriched with options per question It can be used for the generation of statistics. Derived from StatisticsUserController
createFieldMap()  : array<string|int, mixed>
This function generates an array containing the fieldcode, and matching data in the same order as the activate script
hasFileUploadQuestion()  : bool
Returns true if the given survey has a File Upload Question Type
createTimingsFieldMap()  : array<string|int, mixed>
This function generates an array containing the fieldcode, and matching data in the same order as the activate script
arraySearchByKey()  : array<string|int, mixed>
buildLabelSetCheckSumArray()  : mixed
getQuestionAttributeValue()  : string
Returns the questionAttribtue value set or '' if not set
questionTitleSort()  : mixed
HTMLEscape()  : mixed
make a string safe to include in an HTML 'value' attribute.
stripCtrlChars()  : string
This function strips UTF-8 control characters from strings, except tabs, CR and LF - it is intended to be used before any response data is saved to the response table
javascriptEscape()  : mixed
jsonEscape()  : mixed
SendEmailMessage()  : bool
This function mails a text $body to the recipient $to.
flattenText()  : string
This functions removes all HTML tags, Javascript, CRs, linefeeds and other strange chars from a given text
getArrayFilterExcludesCascadesForGroup()  : array<string|int, mixed>
getArrayFilterExcludesCascadesForGroup() queries the database and produces a list of array_filter_exclude questions and targets with in the same group
createPassword()  : mixed
languageDropdown()  : mixed
languageDropdownClean()  : string
Creates a <select> HTML element for language selection for this survey
rmdirr()  : bool
This function removes a directory recursively
CSVUnquote()  : mixed
This function removes surrounding and masking quotes from the CSV field
incompleteAnsFilterState()  : string|bool
This function return actual completion state
isCaptchaEnabled()  : bool|null
isCaptchaEnabled($screen, $usecaptchamode)
tableExists()  : bool
Check if a table does exist in the database
isTokenCompletedDatestamped()  : mixed
dateShift()  : string
example usage $date = "2006-12-31 21:00"; $shift "+6 hours"; // could be days, weeks... see function strtotime() for usage
getBounceEmail()  : mixed
getEmailFormat()  : mixed
hasTemplateManageRights()  : mixed
translateLinks()  : string
Translate links which are in any answer/question/survey/email template/label set to their new counterpart
checkOldLinks()  : bool
Returns true if there are old links in answer/question/survey/email template/label set texts.
reverseTranslateFieldNames()  : array<string|int, mixed>|bool
This function creates the old fieldnames for survey import
hasResources()  : bool
put your comment there.
randomChars()  : string
Creates a random sequence of characters
conditionalNewlineToBreak()  : mixed
used to translate simple text to html (replacing \n with <br />
breakToNewline()  : mixed
safeDie()  : void
Provides a safe way to end the application
fixCKeditorText()  : mixed
filterForAttributes()  : bool
This is a helper function for getAttributeFieldNames
getAttributeFieldNames()  : array<string|int, mixed>
Retrieves the attribute field names from the related survey participants table
getParticipantAttributes()  : array<string|int, mixed>
Returns the full list of attribute token fields including the properties for each field Use this instead of plain Survey::model()->findByPk($iSurveyID)->tokenAttributes calls because Survey::model()->findByPk($iSurveyID)->tokenAttributes may contain old descriptions where the fields does not physically exist
getTokenFieldsAndNames()  : array<string|int, mixed>
Retrieves the attribute names from the related survey participants table
stripJavaScript()  : string
This function strips any content between and including <javascript> tags
showJavaScript()  : string
This function converts emebedded Javascript to Text
cleanTempDirectory()  : mixed
This function cleans files from the temporary directory being older than 1 day
useFirebug()  : mixed
convertDateTimeFormat()  : string
This is a convenience function for the coversion of datetime values
convertToGlobalSettingFormat()  : string
This is a convenience function to convert any date, in any date format, to the global setting date format Check if the time shoul be rendered also
removeBOM()  : string
This function removes the UTF-8 Byte Order Mark from a string
getTemplatePath()  : string
This function returns the complete directory path to a given template name
getTemplateURL()  : string
This function returns the complete URL path to a given template name
getSubQuestions()  : array<string|int, mixed>
Return an array of subquestions for a given sid/qid
getXMLWriter()  : mixed
Wrapper function to retrieve an xmlwriter object and do error handling if it is not compiled into PHP
SSLRedirect()  : mixed
SSLRedirect() generates a redirect URL for the appropriate SSL mode then applies it.
enforceSSLMode()  : mixed
enforceSSLMode() $force_ssl is on or off, it checks if the current request is to HTTPS (or not). If $force_ssl is on, and the request is not to HTTPS, it redirects the request to the HTTPS version of the URL, if the request is to HTTPS, it rewrites all the URL variables so they also point to HTTPS.
getFullResponseTable()  : array<string|int, mixed>
Creates an array with details on a particular response for display purposes Used in Print answers, Detailed response view and Detailed admin notification email
isNumericInt()  : bool|int
Check if $str is an integer, or string representation of an integer
short_implode()  : string
Implode and sort content array for very long arrays
includeKeypad()  : mixed
Include Keypad headers
translateInsertansTags()  : mixed
This function replaces the old insertans tags with new ones across a survey
replaceExpressionCodes()  : mixed
Replaces EM variable codes in a current survey with a new one
cleanLanguagesFromSurvey()  : void
cleanLanguagesFromSurvey() removes any languages from survey tables that are not in the passed list
fixLanguageConsistency()  : bool
fixLanguageConsistency() fixes missing groups, questions, answers, quotas & assessments for languages on a survey
getLastInsertID()  : string
Retrieves the last Insert ID realiable for cross-DB applications
getGroupDepsForConditions()  : array<string|int, mixed>
getGroupDepsForConditions() get Dependencies between groups caused by conditions
getQuestDepsForConditions()  : array<string|int, mixed>
getQuestDepsForConditions() get Dependencies between groups caused by conditions
dbQuoteAll()  : string
Escapes a text value for db
checkMoveQuestionConstraintsForConditions()  : array<string|int, mixed>
checkMoveQuestionConstraintsForConditions()
shouldFilterUserGroupList()  : mixed
Determines whether the list of user groups will need filtering before viewing.
getUserGroupList()  : mixed
Get a list of all user groups All user group or filtered according to usercontrolSameGroupPolicy
modifyDatabase()  : bool
Run an arbitrary sequence of semicolon-delimited SQL commands
getLabelSets()  : array<string|int, mixed>
Returns labelsets for given language(s), or for all if null
getHeader()  : string
get the header
doHeader()  : mixed
getPrintableHeader()  : string
This function returns the header for the printable survey
getFooter()  : string
This function returns the Footer as result string If you want to echo the Footer use doFooter()!
doFooter()  : mixed
fixSubquestions()  : mixed
This function fixes the group ID and type on all subquestions, or removes the subquestions if the parent question's type doesn't allow them.
ls_json_encode()  : mixed
Must use ls_json_encode to json_encode content, otherwise LimeExpressionManager will think that the associative arrays are expressions and try to parse them.
json_decode_ls()  : mixed
Decode a json string, sometimes needs stripslashes
aEncodingsArray()  : array<string|int, mixed>
Return accepted codingsArray for importing files
ellipsize()  : string
Ellipsize String
getIPAddress()  : string
This function tries to returns the 'real' IP address under all configurations Do not rely security-wise on the detected IP address as except for REMOTE_ADDR all fields could be manipulated by the web client
getRealIPAddress()  : string
This function returns the real IP address and should mainly be used for security sensitive purposes If you want to use the IP address for language detection or similar, use getIPAddress() instead
getBrowserLanguage()  : mixed
This function tries to find out a valid language code for the language of the browser used If it cannot find it it will return the default language from global settings
array_diff_assoc_recursive()  : mixed
folderSize()  : int
Calculate folder size NB: If this function is changed, please notify LimeSurvey GmbH.
humanFilesize()  : string
Format size in human readable format.
convertPHPSizeToBytes()  : int
This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)
getMaximumFileUploadSize()  : mixed
decodeTokenAttributes()  : array<string|int, mixed>|mixed
Decodes token attribute data because due to bugs in the past it can be written in JSON or be serialized - future format should be JSON as serialized data can be exploited
getSerialClass()  : string|null
regenerateCSRFToken()  : mixed
Force Yii to create a new CSRF token by removing the old one
get_absolute_path()  : string
A function to remove ../ or ./ from paths to prevent directory traversal
isJson()  : bool
Check if string is JSON array
isAssociativeArray()  : bool
Check if array is associative
createRandomTempDir()  : string
Create a directory in tmp dir using a random string
getRandomString()  : string
Generate a random string, using openssl if available, else using md5
crypto_rand_secure()  : string
Get a random number between two values using openssl_random_pseudo_bytes
isZipBomb()  : int
Test if a given zip file is Zip Bomb see comment here : http://php.net/manual/en/function.zip-entry-filesize.php
get_zip_originalsize()  : int
Get the original size of a zip archive to prevent Zip Bombing see comment here : http://php.net/manual/en/function.zip-entry-filesize.php
safecount()  : int
PHP7 has created a little nasty bomb with count throwing erroros on uncountables This is to "fix" this problem
switchMSSQLIdentityInsert()  : void
This function switches identity insert on/off for the MSSQL database
resourceExtractFilter()  : mixed
Helper to filter the contents of a .zip file uploaded into the file manager
recursive_preg_replace()  : string|array<string|int, mixed>
Applies preg_replace recursively until $recursion_limit is exceeded or no more replacements are done.
standardDeviation()  : float
Returns the standard deviation of supplied $numbers
isAbsolutePath()  : bool
Checks if the specified path is absolute.
csvEscape()  : string
Escapes a string for use in a CSV file

Functions

gT()

Returns $sToTranslate translated to $sLanguage (defaults to lang set in session) escaped with $sEscapeMode

gT(string $sToTranslate[, string $sEscapeMode = 'html' ][, string $sLanguage = null ]) : string
Parameters
$sToTranslate : string
$sEscapeMode : string = 'html'

Valid values are html (this is the default, js and unescaped)

$sLanguage : string = null
Return values
string

eT()

As gT(), but echoes directly

eT(string $sToTranslate[, string $sEscapeMode = 'html' ]) : void
Parameters
$sToTranslate : string
$sEscapeMode : string = 'html'

ngT()

Translation helper function for plural forms

ngT(string $sTextToTranslate, int $iCount[, string $sEscapeMode = 'html' ]) : string
Parameters
$sTextToTranslate : string
$iCount : int
$sEscapeMode : string = 'html'
Return values
string

neT()

Translation helper function for plural forms which outputs right away

neT(string $sToTranslate, int $iCount[, string $sEscapeMode = 'html' ]) : mixed
Parameters
$sToTranslate : string
$iCount : int
$sEscapeMode : string = 'html'

quoteText()

Quotes a translation according to purpose if sEscapeMode is null, we use HTML method because probably we had to specify null as sEscapeMode upstream

quoteText(mixed $sText[, string $sEscapeMode = 'html' ]) : mixed|string
Parameters
$sText : mixed

Text to quote

$sEscapeMode : string = 'html'

Optional - One of the values 'html','js' or 'unescaped' - defaults to 'html'

Return values
mixed|string

getSurveyList()

getSurveyList() Queries the database (survey table) for a list of existing surveys

getSurveyList([bool $bReturnArray = false ]) : string|array<string|int, mixed>
Parameters
$bReturnArray : bool = false

If set to true an array instead of an HTML option list is given back (unused by core (2023-04-12))

Return values
string|array<string|int, mixed>

This string is returned containing formatted list of existing surveys

getGidPrevious()

getGidPrevious() returns the Gid of the group prior to the current active group

getGidPrevious(int $surveyid, int $gid) : int|string
Parameters
$surveyid : int
$gid : int
Return values
int|string

The GID of the previous group or blank string if no group

getGidNext()

getGidNext() returns the Gid of the group next to the current active group

getGidNext(int $surveyid, int $gid) : int|string
Parameters
$surveyid : int
$gid : int
Return values
int|string

The Gid of the next group or blank string if no group

convertGETtoPOST()

convertGETtoPOST a function to create a post Request from get parameters !!! This functions result has to be wrappen in singlequotes!

convertGETtoPOST(string $url) : string
Parameters
$url : string

| The complete url with all parameters

Return values
string

| The onclick action for the element

calculateTotalFileUploadUsage()

This function calculates how much space is actually used by all files uploaded using the File Upload question type

calculateTotalFileUploadUsage() : mixed
Tags
returns

integer Actual space used in MB

getDirectorySize()

getDirectorySize(string $directory) : int
Parameters
$directory : string
Return values
int

getMaxGroupOrder()

Queries the database for the maximum sortorder of a group and returns the next higher one.

getMaxGroupOrder(int $surveyid) : int
Parameters
$surveyid : int

The survey ID

Return values
int

Next free sortorder digit

getGroupOrder()

Queries the database for the sortorder of a group.

getGroupOrder(mixed $gid) : int
Parameters
$gid : mixed

The groups ID

Return values
int

The sortorder digit

getMaxQuestionOrder()

Queries the database for the maximum sort order of questions inside question group.

getMaxQuestionOrder(int $gid) : int
Parameters
$gid : int
Return values
int

setupColumns()

setupColumns() defines all the html tags to be wrapped around various list type answers.

setupColumns(int $columns, int $answer_count[, string $wrapperclass = "" ][, string $itemclass = "" ]) : array<string|int, mixed>
Parameters
$columns : int
  • the number of columns, usually supplied by $dcols
$answer_count : int
  • the number of answers to a question, usually supplied by $anscount
$wrapperclass : string = ""
  • a global class for the wrapper
$itemclass : string = ""
  • a class for the item
Tags
deprecated

Don't use anymore. Only usage left in printabel survey where it needs to be replaced

It returns an array with the following items: $wrapper['whole-start'] = Opening wrapper for the whole list $wrapper['whole-end'] = closing wrapper for the whole list $wrapper['col-devide'] = normal column devider $wrapper['col-devide-last'] = the last column devider (to allow for different styling of the last column $wrapper['item-start'] = opening wrapper tag for individual option $wrapper['item-start-other'] = opening wrapper tag for other option $wrapper['item-start-noanswer'] = opening wrapper tag for no answer option $wrapper['item-end'] = closing wrapper tag for individual option $wrapper['maxrows'] = maximum number of rows in each column $wrapper['cols'] = Number of columns to be inserted (and checked against)


Columns are a problem. Really there is no perfect solution to columns at the moment.

  • Using Tables is problematic semanticly.
  • Using inline or float to create columns, causes the answers flows horizontally, not vertically which is not ideal visually.
  • Using CSS3 columns is also a problem because of browser support and also because if you have answeres split across two or more lines, and those answeres happen to fall at the bottom of a column, the answer might be split across columns as well as lines.
  • Using nested unordered list with the first level of <LI>s floated is the same as using tables and so is bad semantically for the same reason tables are bad.
  • Breaking the unordered lists into consecutive floated unordered lists is not great semantically but probably not as bad as using tables.

Because I haven't been able to decide which option is the least bad, I have handed over that responsibility to the admin who sets LimeSurvey up on their server.

There are four options: 'css' using one of the various CSS only methods for rendering columns. (Check the CSS file for your chosen template to see how columns are defined.) 'ul' using multiple floated unordered lists. (DEFAULT) 'table' using conventional tables based layout. NULL blocks the use of columns

'ul' is the default because it's the best possible compromise between semantic markup and visual layout.

Return values
array<string|int, mixed>

with all the various opening and closing tags to generate a set of columns.

alternation()

alternation([mixed $alternate = '' ][, mixed $type = 'col' ]) : mixed
Parameters
$alternate : mixed = ''
$type : mixed = 'col'

longestString()

longestString() returns the length of the longest string past to it.

longestString(mixed $new_string, int $longest_length) : int
Parameters
$new_string : mixed
$longest_length : int
Tags
peram

string $new_string

peram

integer $longest_length length of the (previously) longest string passed to it.

Return values
int

representing the length of the longest string passed (updated if $new_string was longer than $longest_length)

usage should look like this: $longest_length = longestString( $new_string , $longest_length );

getGroupList3()

getGroupList3(mixed $gid, mixed $surveyid) : mixed
Parameters
$gid : mixed
$surveyid : mixed

getGroupListLang()

put your comment there.

getGroupListLang(mixed $gid, mixed $language, mixed $surveyid) : string

..

Parameters
$gid : mixed
$language : mixed
$surveyid : mixed
Return values
string

getUserList()

Returns a user list. If 'usercontrolSameGroupPolicy' is set and set to true, only users which are in the same group as me (--> logged in user) will be returned. Superadmin always gets the full list of users.

getUserList([ $outputformat = 'fullinfoarray' ]) : array<string|int, mixed>
Parameters
$outputformat : = 'fullinfoarray'

string could be 'onlyuidarray' which only returns array with userids, default is 'fullinfoarray'

Return values
array<string|int, mixed>

returns a list of user ids (param='onlyuidarray') or a list with full user details (e.g. uid, name, full_name etc.)

getSurveyInfo()

Gets all survey infos in one big array including the language specific settings

getSurveyInfo(int $surveyid[, string $languagecode = '' ][, bool $force = false ]) : array<string|int, mixed>|bool
Parameters
$surveyid : int

The survey ID

$languagecode : string = ''

The language code - if not given the base language of the particular survey is used

$force : bool = false

If true, don't use memoization

Return values
array<string|int, mixed>|bool

Returns array with survey info or false, if survey does not exist

templateDefaultTexts()

Returns the default email template texts as array

templateDefaultTexts(mixed $sLanguage[, string $mode = 'html' ][, mixed $sNewlines = 'text' ]) : array<string|int, mixed>
Parameters
$sLanguage : mixed

Required language translationb object

$mode : string = 'html'

Escape mode for the translation function

$sNewlines : mixed = 'text'
Tags
todo

Move to defaulttexts helper

Return values
array<string|int, mixed>

groupOrderThenQuestionOrder()

Compares two elements from an array (passed by the usort function) and returns -1, 0 or 1 depending on the result of the comparison of the sort order of the group_order and question_order field Used by : - remotecontrol_handle->export_statistics with merging group and question attributes (all in same array) - checkQuestions() in activate_helper function with ?

groupOrderThenQuestionOrder(mixed $a, mixed $b) : int
Parameters
$a : mixed
$b : mixed
Return values
int

fixMovedQuestionConditions()

fixMovedQuestionConditions(int $qid, mixed $oldgid, int $newgid[, int $iSurveyID = null ]) : mixed
Parameters
$qid : int
$oldgid : mixed
$newgid : int
$iSurveyID : int = null

returnGlobal()

This function returns POST/REQUEST vars, for some vars like SID and others they are also sanitized TODO: extends Yii:getParam

returnGlobal(string $stringname[, bool $bRestrictToString = false ]) : array<string|int, mixed>|bool|mixed|int|null
Parameters
$stringname : string
$bRestrictToString : bool = false
Return values
array<string|int, mixed>|bool|mixed|int|null

getExtendedAnswer()

getExtendedAnswer(int $iSurveyID, string $sFieldCode, string $sValue, string $sLanguage) : string
Parameters
$iSurveyID : int

The Survey ID

$sFieldCode : string

Field code of the particular field

$sValue : string

The stored response value

$sLanguage : string

Initialized limesurvey_lang object for the resulting response data

Return values
string

validateEmailAddress()

Validate an email address - also supports IDN email addresses

validateEmailAddress(mixed $sEmailAddress) : mixed
Parameters
$sEmailAddress : mixed

Email address to check

Tags
deprecated

: use LimeMailer::validateAddress($sEmailAddress);

returns

True/false for valid/invalid

validateEmailAddresses()

Validate an list of email addresses - either as array or as semicolon-limited text

validateEmailAddresses(string $aEmailAddressList) : string
Parameters
$aEmailAddressList : string

Email address to check

Tags
deprecated

: use LimeMailer::validateAddresses($aEmailAddressList);

returns

array

Return values
string

List with valid email addresses - invalid email addresses are filtered - false if none of the email addresses are valid

createCompleteSGQA()

This functions generates a a summary containing the SGQA for questions of a survey, enriched with options per question It can be used for the generation of statistics. Derived from StatisticsUserController

createCompleteSGQA(int $iSurveyID, array<string|int, mixed> $aFilters, string $sLanguage) : array<string|int, mixed>
Parameters
$iSurveyID : int

Id of the Survey in question

$aFilters : array<string|int, mixed>

an array which is the result of a query in Questions model

$sLanguage : string
Return values
array<string|int, mixed>

The summary

createFieldMap()

This function generates an array containing the fieldcode, and matching data in the same order as the activate script

createFieldMap(Survey $survey[, string $style = 'short' ][, bool|null $force_refresh = false ][, bool|int $questionid = false ][, string $sLanguage = '' ][, array<string|int, mixed> &$aDuplicateQIDs = array() ]) : array<string|int, mixed>
Parameters
$survey : Survey

Survey ActiveRecord model

$style : string = 'short'

'short' (default) or 'full' - full creates extra information like default values

$force_refresh : bool|null = false
  • Forces to really refresh the array, not just take the session copy
$questionid : bool|int = false

Limit to a certain qid only (for question preview) - default is false

$sLanguage : string = ''

The language to use

$aDuplicateQIDs : array<string|int, mixed> = array()
Return values
array<string|int, mixed>

hasFileUploadQuestion()

Returns true if the given survey has a File Upload Question Type

hasFileUploadQuestion(int $iSurveyID) : bool
Parameters
$iSurveyID : int
Return values
bool

createTimingsFieldMap()

This function generates an array containing the fieldcode, and matching data in the same order as the activate script

createTimingsFieldMap(string $surveyid[, string $style = 'full' ][, bool $force_refresh = false ][, int $questionid = false ][, string $sQuestionLanguage = null ]) : array<string|int, mixed>
Parameters
$surveyid : string

The Survey ID

$style : string = 'full'

'short' (default) or 'full' - full creates extra information like default values

$force_refresh : bool = false
  • Forces to really refresh the array, not just take the session copy
$questionid : int = false

Limit to a certain qid only (for question preview) - default is false

$sQuestionLanguage : string = null

The language to use

Return values
array<string|int, mixed>

arraySearchByKey()

arraySearchByKey(mixed $needle, mixed $haystack, string $keyname[, int $maxanswers = "" ]) : array<string|int, mixed>
Parameters
$needle : mixed
$haystack : mixed
$keyname : string
$maxanswers : int = ""
Return values
array<string|int, mixed>

buildLabelSetCheckSumArray()

buildLabelSetCheckSumArray() : mixed

getQuestionAttributeValue()

Returns the questionAttribtue value set or '' if not set

getQuestionAttributeValue( $questionAttributeArray, string $attributeName[,  $language = '' ]) : string
Parameters
$questionAttributeArray :
$attributeName : string
$language : = ''

string Optional: The language if the particualr attributes is localizable

Tags
author:

lemeur

Return values
string

questionTitleSort()

questionTitleSort(mixed $a, mixed $b) : mixed
Parameters
$a : mixed
$b : mixed

HTMLEscape()

make a string safe to include in an HTML 'value' attribute.

HTMLEscape(mixed $str) : mixed
Parameters
$str : mixed
Tags
deprecated

If you need this you are doing something wrong. Use CHTML functions instead.

stripCtrlChars()

This function strips UTF-8 control characters from strings, except tabs, CR and LF - it is intended to be used before any response data is saved to the response table

stripCtrlChars(mixed $sValue) : string
Parameters
$sValue : mixed

A string to be sanitized

Return values
string

A sanitized string, otherwise the unmodified original variable

javascriptEscape()

javascriptEscape(string $str[, mixed $strip_tags = false ][, mixed $htmldecode = false ]) : mixed
Parameters
$str : string
$strip_tags : mixed = false
$htmldecode : mixed = false

jsonEscape()

jsonEscape(string $str[, mixed $strip_tags = false ][, mixed $htmldecode = false ]) : mixed
Parameters
$str : string
$strip_tags : mixed = false
$htmldecode : mixed = false

SendEmailMessage()

This function mails a text $body to the recipient $to.

SendEmailMessage(string $body, mixed $subject, mixed $to, string $from, mixed $sitename[, bool $ishtml = false ][, mixed $bouncemail = null ][, mixed $attachments = null ][, mixed $customheaders = "" ]) : bool

You can use more than one recipient when using a semicolon separated string with recipients.

Parameters
$body : string

Body text of the email in plain text or HTML

$subject : mixed

Email subject

$to : mixed

Array with several email addresses or single string with one email address

$from : string
$sitename : mixed
$ishtml : bool = false
$bouncemail : mixed = null
$attachments : mixed = null
$customheaders : mixed = ""
Tags
deprecated

: leave it in 4.0 for plugins ? Must remove in 5.0 at minima.

Return values
bool

If successful returns true

flattenText()

This functions removes all HTML tags, Javascript, CRs, linefeeds and other strange chars from a given text

flattenText(string $sTextToFlatten[, bool $bKeepSpan = false ][, bool $bDecodeHTMLEntities = false ][, string $sCharset = 'UTF-8' ][, bool $bStripNewLines = true ]) : string
Parameters
$sTextToFlatten : string

Text you want to clean

$bKeepSpan : bool = false

set to true for keep span, used for expression manager. Default: false

$bDecodeHTMLEntities : bool = false

If set to true then all HTML entities will be decoded to the specified charset. Default: false

$sCharset : string = 'UTF-8'

Charset to decode to if $decodeHTMLEntities is set to true. Default: UTF-8

$bStripNewLines : bool = true

strip new lines if true, if false replace all new line by \r\n. Default: true

Return values
string

Cleaned text

getArrayFilterExcludesCascadesForGroup()

getArrayFilterExcludesCascadesForGroup() queries the database and produces a list of array_filter_exclude questions and targets with in the same group

getArrayFilterExcludesCascadesForGroup(mixed $surveyid[, mixed $gid = "" ][, mixed $output = "qid" ]) : array<string|int, mixed>
Parameters
$surveyid : mixed
$gid : mixed = ""
$output : mixed = "qid"
Return values
array<string|int, mixed>

a keyed nested array, keyed by the qid of the question, containing cascade information

createPassword()

createPassword([mixed $iPasswordLength = 12 ]) : mixed
Parameters
$iPasswordLength : mixed = 12

languageDropdown()

languageDropdown(mixed $surveyid, mixed $selected) : mixed
Parameters
$surveyid : mixed
$selected : mixed

languageDropdownClean()

Creates a <select> HTML element for language selection for this survey

languageDropdownClean(int $surveyid, string $selected) : string
Parameters
$surveyid : int
$selected : string

The selected language

Return values
string

rmdirr()

This function removes a directory recursively

rmdirr(string $dirname) : bool
Parameters
$dirname : string
Return values
bool

CSVUnquote()

This function removes surrounding and masking quotes from the CSV field

CSVUnquote(mixed $field) : mixed
Parameters
$field : mixed

incompleteAnsFilterState()

This function return actual completion state

incompleteAnsFilterState() : string|bool
Return values
string|bool

(complete|incomplete|all) or false

isCaptchaEnabled()

isCaptchaEnabled($screen, $usecaptchamode)

isCaptchaEnabled(string $screen[, mixed $captchamode = '' ]) : bool|null
Parameters
$screen : string
  • the screen name for which to test captcha activation
$captchamode : mixed = ''
Return values
bool|null
  • returns true if captcha must be enabled

tableExists()

Check if a table does exist in the database

tableExists(string $sTableName) : bool
Parameters
$sTableName : string

Table name to check for (without dbprefix!))

Return values
bool

True or false if table exists or not

isTokenCompletedDatestamped()

isTokenCompletedDatestamped(mixed $thesurvey) : mixed
Parameters
$thesurvey : mixed

dateShift()

example usage $date = "2006-12-31 21:00"; $shift "+6 hours"; // could be days, weeks... see function strtotime() for usage

dateShift(string $date, string $dformat, string $shift) : string

echo sql_date_shift($date, "Y-m-d H:i:s", $shift);

will output: 2007-01-01 03:00:00

Parameters
$date : string
$dformat : string
$shift : string
Return values
string

getBounceEmail()

getBounceEmail(mixed $surveyid) : mixed
Parameters
$surveyid : mixed

getEmailFormat()

getEmailFormat(mixed $surveyid) : mixed
Parameters
$surveyid : mixed

hasTemplateManageRights()

hasTemplateManageRights(mixed $userid, mixed $sThemeFolder) : mixed
Parameters
$userid : mixed
$sThemeFolder : mixed

Translate links which are in any answer/question/survey/email template/label set to their new counterpart

translateLinks(string $sType, mixed $iOldSurveyID, mixed $iNewSurveyID, string $sString[, bool $isLocalPath = false ]) : string
Parameters
$sType : string

'survey' or 'label'

$iOldSurveyID : mixed

Source SurveyId to be replaced

$iNewSurveyID : mixed

New SurveyId to be used

$sString : string

Link (url or local path) to be translated

$isLocalPath : bool = false

Indicates if the link ($sString) is a local path or a url.

Return values
string

Returns true if there are old links in answer/question/survey/email template/label set texts.

checkOldLinks(string $type, mixed $oldSurveyId, mixed $string) : bool
Parameters
$type : string

'survey' or 'label'

$oldSurveyId : mixed
$string : mixed
Return values
bool

True if the provided string includes links to the old survey. If the type is not 'survey' or 'label', it returns false.

reverseTranslateFieldNames()

This function creates the old fieldnames for survey import

reverseTranslateFieldNames(mixed $iOldSID, int $iNewSID, array<string|int, mixed> $aGIDReplacements, array<string|int, mixed> $aQIDReplacements) : array<string|int, mixed>|bool
Parameters
$iOldSID : mixed

The old survey ID

$iNewSID : int

The new survey ID

$aGIDReplacements : array<string|int, mixed>

An array with group ids (oldgid=>newgid)

$aQIDReplacements : array<string|int, mixed>

An array with question ids (oldqid=>newqid)

Return values
array<string|int, mixed>|bool

hasResources()

put your comment there.

hasResources(int $id[, string $type = 'survey' ]) : bool

..

Parameters
$id : int
$type : string = 'survey'
Return values
bool

randomChars()

Creates a random sequence of characters

randomChars(int $length[, string $pattern = "23456789abcdefghijkmnpqrstuvwxyz" ]) : string
Parameters
$length : int

Length of resulting string

$pattern : string = "23456789abcdefghijkmnpqrstuvwxyz"

To define which characters should be in the resulting string

Return values
string

conditionalNewlineToBreak()

used to translate simple text to html (replacing \n with <br />

conditionalNewlineToBreak(string $mytext, mixed $ishtml[, mixed $encoded = '' ]) : mixed
Parameters
$mytext : string
$ishtml : mixed
$encoded : mixed = ''

breakToNewline()

breakToNewline(string $data) : mixed
Parameters
$data : string

safeDie()

Provides a safe way to end the application

safeDie(string $sText) : void
Parameters
$sText : string
Tags
todo

This should probably never be used, since it returns 0 from CLI and makes PHPUnit think all is fine :(

fixCKeditorText()

fixCKeditorText(string $str) : mixed
Parameters
$str : string

filterForAttributes()

This is a helper function for getAttributeFieldNames

filterForAttributes(string $fieldname) : bool
Parameters
$fieldname : string
Return values
bool

getAttributeFieldNames()

Retrieves the attribute field names from the related survey participants table

getAttributeFieldNames(mixed $iSurveyID) : array<string|int, mixed>
Parameters
$iSurveyID : mixed

The survey ID

Return values
array<string|int, mixed>

The fieldnames

getParticipantAttributes()

Returns the full list of attribute token fields including the properties for each field Use this instead of plain Survey::model()->findByPk($iSurveyID)->tokenAttributes calls because Survey::model()->findByPk($iSurveyID)->tokenAttributes may contain old descriptions where the fields does not physically exist

getParticipantAttributes(int $iSurveyID) : array<string|int, mixed>
Parameters
$iSurveyID : int

The Survey ID

Return values
array<string|int, mixed>

getTokenFieldsAndNames()

Retrieves the attribute names from the related survey participants table

getTokenFieldsAndNames(mixed $surveyid[, bool $bOnlyAttributes = false ]) : array<string|int, mixed>
Parameters
$surveyid : mixed

The survey ID

$bOnlyAttributes : bool = false

Set this to true if you only want the fieldnames of the additional attribue fields - defaults to false

Return values
array<string|int, mixed>

The fieldnames as key and names as value in an Array

stripJavaScript()

This function strips any content between and including <javascript> tags

stripJavaScript(string|null $sContent) : string
Parameters
$sContent : string|null

String to clean

Return values
string

Cleaned string

showJavaScript()

This function converts emebedded Javascript to Text

showJavaScript(string $sContent) : string
Parameters
$sContent : string

String to clean

Return values
string

Cleaned string

cleanTempDirectory()

This function cleans files from the temporary directory being older than 1 day

cleanTempDirectory() : mixed
Tags
todo

Make the days configurable

convertDateTimeFormat()

This is a convenience function for the coversion of datetime values

convertDateTimeFormat(mixed $value, string $fromdateformat, mixed $todateformat) : string
Parameters
$value : mixed
$fromdateformat : string
$todateformat : mixed
Return values
string

convertToGlobalSettingFormat()

This is a convenience function to convert any date, in any date format, to the global setting date format Check if the time shoul be rendered also

convertToGlobalSettingFormat(string $sDate[, bool $withTime = false ]) : string
Parameters
$sDate : string
$withTime : bool = false
Return values
string

removeBOM()

This function removes the UTF-8 Byte Order Mark from a string

removeBOM([string $str = "" ]) : string
Parameters
$str : string = ""
Return values
string

getTemplatePath()

This function returns the complete directory path to a given template name

getTemplatePath([mixed $sTemplateName = '' ]) : string
Parameters
$sTemplateName : mixed = ''
Return values
string

getTemplateURL()

This function returns the complete URL path to a given template name

getTemplateURL(mixed $sTemplateName) : string
Parameters
$sTemplateName : mixed
Return values
string

getSubQuestions()

Return an array of subquestions for a given sid/qid

getSubQuestions(int $sid, int $qid, string $sLanguage) : array<string|int, mixed>
Parameters
$sid : int
$qid : int
$sLanguage : string

Language of the subquestion text

Return values
array<string|int, mixed>

getXMLWriter()

Wrapper function to retrieve an xmlwriter object and do error handling if it is not compiled into PHP

getXMLWriter() : mixed

SSLRedirect()

SSLRedirect() generates a redirect URL for the appropriate SSL mode then applies it.

SSLRedirect(string $enforceSSLMode) : mixed

(Was redirect() before CodeIgniter port.)

Parameters
$enforceSSLMode : string

string 's' or '' (empty).

enforceSSLMode()

enforceSSLMode() $force_ssl is on or off, it checks if the current request is to HTTPS (or not). If $force_ssl is on, and the request is not to HTTPS, it redirects the request to the HTTPS version of the URL, if the request is to HTTPS, it rewrites all the URL variables so they also point to HTTPS.

enforceSSLMode() : mixed

getFullResponseTable()

Creates an array with details on a particular response for display purposes Used in Print answers, Detailed response view and Detailed admin notification email

getFullResponseTable(mixed $iSurveyID, mixed $iResponseID, mixed $sLanguageCode[, bool $bHonorConditions = true ]) : array<string|int, mixed>
Parameters
$iSurveyID : mixed
$iResponseID : mixed
$sLanguageCode : mixed
$bHonorConditions : bool = true

Apply conditions

Return values
array<string|int, mixed>

isNumericInt()

Check if $str is an integer, or string representation of an integer

isNumericInt(string $mStr) : bool|int
Parameters
$mStr : string
Return values
bool|int

short_implode()

Implode and sort content array for very long arrays

short_implode(string $sDelimeter, mixed $sHyphen, array<string|int, mixed> $aArray) : string
Parameters
$sDelimeter : string
$sHyphen : mixed
$aArray : array<string|int, mixed>
Return values
string

String showing array content

includeKeypad()

Include Keypad headers

includeKeypad() : mixed

translateInsertansTags()

This function replaces the old insertans tags with new ones across a survey

translateInsertansTags(string $newsid, string $oldsid, mixed $fieldnames) : mixed
Parameters
$newsid : string

Old SID

$oldsid : string

New SID

$fieldnames : mixed

Array array('oldfieldname'=>'newfieldname')

replaceExpressionCodes()

Replaces EM variable codes in a current survey with a new one

replaceExpressionCodes(int $iSurveyID, mixed $aCodeMap) : mixed
Parameters
$iSurveyID : int

The survey ID

$aCodeMap : mixed

The codemap array (old_code=>new_code)

cleanLanguagesFromSurvey()

cleanLanguagesFromSurvey() removes any languages from survey tables that are not in the passed list

cleanLanguagesFromSurvey(mixed $iSurveyID, string $availlangs[, mixed $baselang = null ]) : void
Parameters
$iSurveyID : mixed
$availlangs : string
  • space separated list of additional languages in survey
$baselang : mixed = null

fixLanguageConsistency()

fixLanguageConsistency() fixes missing groups, questions, answers, quotas & assessments for languages on a survey

fixLanguageConsistency(int $sid[, string $availlangs = '' ][, string $baselang = '' ]) : bool
Parameters
$sid : int
  • the currently selected survey
$availlangs : string = ''
  • space separated list of additional languages in survey - if empty all additional languages of a survey are checked against the base language
$baselang : string = ''
  • language to use as base (useful when changing the base language) - if empty, it will be picked from the survey
Return values
bool
  • always returns true

getLastInsertID()

Retrieves the last Insert ID realiable for cross-DB applications

getLastInsertID(string $sTableName) : string
Parameters
$sTableName : string

Needed for Postgres and MSSQL

Return values
string

getGroupDepsForConditions()

getGroupDepsForConditions() get Dependencies between groups caused by conditions

getGroupDepsForConditions(string $sid[, string $depgid = "all" ][, string $targgid = "all" ][, string $indexby = "by-depgid" ]) : array<string|int, mixed>
Parameters
$sid : string
  • the currently selected survey
$depgid : string = "all"
  • (optional) get only the dependencies applying to the group with gid depgid
$targgid : string = "all"
  • (optional) get only the dependencies for groups dependents on group targgid
$indexby : string = "by-depgid"
  • (optional) "by-depgid" for result indexed with $res[$depgid][$targgid] "by-targgid" for result indexed with $res[$targgid][$depgid]
Return values
array<string|int, mixed>
  • returns an array describing the conditions or NULL if no dependecy is found

Example outupt assumin $index-by="by-depgid": Array ( [125] => Array // Group Id 125 is dependent on ( [123] => Array // Group Id 123 ( [depgpname] => G3 // GID-125 has name G3 [targetgpname] => G1 // GID-123 has name G1 [conditions] => Array ( [189] => Array // Because Question Id 189 ( [0] => 9 // Have condition 9 set [1] => 10 // and condition 10 set [2] => 14 // and condition 14 set )

                   )

           )

       [124] => Array         // GID 125 is also dependent on GID 124
           (
               [depgpname] => G3
               [targetgpname] => G2
               [conditions] => Array
                   (
                       [189] => Array // Because Question Id 189 have conditions set
                           (
                               [0] => 11
                           )

                       [215] => Array // And because Question Id 215 have conditions set
                           (
                               [0] => 12
                           )

                   )

           )

   )

)

Usage example:

  • Get all group dependencies for SID $sid indexed by depgid: $result=getGroupDepsForConditions($sid);
  • Get all group dependencies for GID $gid in survey $sid indexed by depgid: $result=getGroupDepsForConditions($sid,$gid);
  • Get all group dependents on group $gid in survey $sid indexed by targgid: $result=getGroupDepsForConditions($sid,"all",$gid,"by-targgid");

getQuestDepsForConditions()

getQuestDepsForConditions() get Dependencies between groups caused by conditions

getQuestDepsForConditions(string $sid[, string $gid = "all" ][, string $depqid = "all" ][, string $targqid = "all" ][, string $indexby = "by-depqid" ][, mixed $searchscope = "samegroup" ]) : array<string|int, mixed>
Parameters
$sid : string
  • the currently selected survey
$gid : string = "all"
  • (optional) only search dependecies inside the Group Id $gid
$depqid : string = "all"
  • (optional) get only the dependencies applying to the question with qid depqid
$targqid : string = "all"
  • (optional) get only the dependencies for questions dependents on question Id targqid
$indexby : string = "by-depqid"
  • (optional) "by-depqid" for result indexed with $res[$depqid][$targqid] "by-targqid" for result indexed with $res[$targqid][$depqid]
$searchscope : mixed = "samegroup"
Return values
array<string|int, mixed>
  • returns an array describing the conditions or NULL if no dependecy is found

Example outupt assumin $index-by="by-depqid": Array ( [184] => Array // Question Id 184 ( [183] => Array // Depends on Question Id 183 ( [0] => 5 // Because of condition Id 5 )

   )

)

Usage example:

  • Get all questions dependencies for Survey $sid and group $gid indexed by depqid: $result=getQuestDepsForConditions($sid,$gid);
  • Get all questions dependencies for question $qid in survey/group $sid/$gid indexed by depqid: $result=getGroupDepsForConditions($sid,$gid,$qid);
  • Get all questions dependents on question $qid in survey/group $sid/$gid indexed by targqid: $result=getGroupDepsForConditions($sid,$gid,"all",$qid,"by-targgid");

dbQuoteAll()

Escapes a text value for db

dbQuoteAll(string $value) : string
Parameters
$value : string
Return values
string

checkMoveQuestionConstraintsForConditions()

checkMoveQuestionConstraintsForConditions()

checkMoveQuestionConstraintsForConditions(string $sid, string $qid[, string $newgid = "all" ]) : array<string|int, mixed>
Parameters
$sid : string
  • the currently selected survey
$qid : string
  • qid of the question you want to check possible moves
$newgid : string = "all"
  • (optional) get only constraints when trying to move to this particular GroupId otherwise, get all moves constraints for this question
Return values
array<string|int, mixed>
  • returns an array describing the conditions Array ( ['notAbove'] = null | Array ( Array ( gid1, group_order1, qid1, cid1 ) ) ['notBelow'] = null | Array ( Array ( gid2, group_order2, qid2, cid2 ) ) )

This should be read as:

  • this question can't be move above group gid1 in position group_order1 because of the condition cid1 on question qid1
  • this question can't be move below group gid2 in position group_order2 because of the condition cid2 on question qid2

shouldFilterUserGroupList()

Determines whether the list of user groups will need filtering before viewing.

shouldFilterUserGroupList() : mixed
Tags
returns

bool

getUserGroupList()

Get a list of all user groups All user group or filtered according to usercontrolSameGroupPolicy

getUserGroupList() : mixed
Tags
returns

array

modifyDatabase()

Run an arbitrary sequence of semicolon-delimited SQL commands

modifyDatabase([string $sqlfile = '' ][, string $sqlstring = '' ]) : bool

Assumes that the input text (file or string) consists of a number of SQL statements ENDING WITH SEMICOLONS. The semicolons MUST be the last character in a line. Lines that are blank or that start with "#" or "--" (postgres) are ignored. Only tested with mysql dump files (mysqldump -p -d limesurvey) Function kindly borrowed by Moodle

Parameters
$sqlfile : string = ''

The path where a file with sql commands can be found on the server.

$sqlstring : string = ''

If no path is supplied then a string with semicolon delimited sql commands can be supplied in this argument.

Return values
bool

Returns true if database was modified successfully.

getLabelSets()

Returns labelsets for given language(s), or for all if null

getLabelSets([string $languages = null ]) : array<string|int, mixed>
Parameters
$languages : string = null
Return values
array<string|int, mixed>

getHeader()

get the header

getHeader([bool $meta = false ]) : string
Parameters
$meta : bool = false

: not used in any call (2016-10-18)

Return values
string

getPrintableHeader()

This function returns the header for the printable survey

getPrintableHeader() : string
Return values
string

getFooter()

This function returns the Footer as result string If you want to echo the Footer use doFooter()!

getFooter() : string
Return values
string

fixSubquestions()

This function fixes the group ID and type on all subquestions, or removes the subquestions if the parent question's type doesn't allow them.

fixSubquestions() : mixed

Optimized for minimum memory usage even on huge databases

ls_json_encode()

Must use ls_json_encode to json_encode content, otherwise LimeExpressionManager will think that the associative arrays are expressions and try to parse them.

ls_json_encode(mixed $content) : mixed
Parameters
$content : mixed

json_decode_ls()

Decode a json string, sometimes needs stripslashes

json_decode_ls(string $jsonString) : mixed
Parameters
$jsonString : string

aEncodingsArray()

Return accepted codingsArray for importing files

aEncodingsArray() : array<string|int, mixed>

Used in vvimport TODO : use in token and

Return values
array<string|int, mixed>

ellipsize()

Ellipsize String

ellipsize(string $sString, int $iMaxLength[, int $fPosition = 1 ][, string $sEllipsis = '&hellip;' ]) : string

This public static function will strip tags from a string, split it at its max_length and ellipsize

Parameters
$sString : string

string to ellipsize

$iMaxLength : int

max length of string

$fPosition : int = 1

int (1|0) or float, .5, .2, etc for position to split

$sEllipsis : string = '&hellip;'

ellipsis ; Default '...'

Return values
string

ellipsized string

getIPAddress()

This function tries to returns the 'real' IP address under all configurations Do not rely security-wise on the detected IP address as except for REMOTE_ADDR all fields could be manipulated by the web client

getIPAddress() : string
Return values
string

Client's IP Address

getRealIPAddress()

This function returns the real IP address and should mainly be used for security sensitive purposes If you want to use the IP address for language detection or similar, use getIPAddress() instead

getRealIPAddress() : string
Return values
string

Client IP Address

getBrowserLanguage()

This function tries to find out a valid language code for the language of the browser used If it cannot find it it will return the default language from global settings

getBrowserLanguage() : mixed

array_diff_assoc_recursive()

array_diff_assoc_recursive(mixed $array1, mixed $array2) : mixed
Parameters
$array1 : mixed
$array2 : mixed

folderSize()

Calculate folder size NB: If this function is changed, please notify LimeSurvey GmbH.

folderSize(string $dir) : int

An exact copy of this function is used to calculate storage limit on LimeSurvey Pro hosting.

Parameters
$dir : string

Folder

Return values
int

Size in bytes.

humanFilesize()

Format size in human readable format.

humanFilesize(int $bytes[, int $decimals = 2 ]) : string
Parameters
$bytes : int
$decimals : int = 2
Return values
string

convertPHPSizeToBytes()

This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)

convertPHPSizeToBytes(string $sSize) : int
Parameters
$sSize : string
Return values
int

The value in bytes

getMaximumFileUploadSize()

getMaximumFileUploadSize() : mixed

decodeTokenAttributes()

Decodes token attribute data because due to bugs in the past it can be written in JSON or be serialized - future format should be JSON as serialized data can be exploited

decodeTokenAttributes(string $tokenAttributeData) : array<string|int, mixed>|mixed
Parameters
$tokenAttributeData : string

The original token attributes as stored in the database

Return values
array<string|int, mixed>|mixed

getSerialClass()

getSerialClass(string $sSerial) : string|null
Parameters
$sSerial : string
Return values
string|null

regenerateCSRFToken()

Force Yii to create a new CSRF token by removing the old one

regenerateCSRFToken() : mixed

get_absolute_path()

A function to remove ../ or ./ from paths to prevent directory traversal

get_absolute_path(string $path) : string
Parameters
$path : string
Return values
string

isJson()

Check if string is JSON array

isJson(string $str) : bool
Parameters
$str : string
Return values
bool

isAssociativeArray()

Check if array is associative

isAssociativeArray(array<string|int, mixed> $array) : bool
Parameters
$array : array<string|int, mixed>
Return values
bool

createRandomTempDir()

Create a directory in tmp dir using a random string

createRandomTempDir([string $dir = null ][, string $prefix = '' ][, int $mode = 0700 ]) : string
Parameters
$dir : string = null

the temp directory (if empty will use the one from configuration)

$prefix : string = ''

wanted prefix for the directory

$mode : int = 0700

wanted file mode for this directory

Return values
string

the path of the created directory

getRandomString()

Generate a random string, using openssl if available, else using md5

getRandomString([int $length = 32 ]) : string
Parameters
$length : int = 32

wanted lenght of the random string (only for openssl mode)

Return values
string

crypto_rand_secure()

Get a random number between two values using openssl_random_pseudo_bytes

crypto_rand_secure(int $min, int $max) : string
Parameters
$min : int
$max : int
Return values
string

isZipBomb()

Test if a given zip file is Zip Bomb see comment here : http://php.net/manual/en/function.zip-entry-filesize.php

isZipBomb(string $zip_filename) : int
Parameters
$zip_filename : string
Return values
int

get_zip_originalsize()

Get the original size of a zip archive to prevent Zip Bombing see comment here : http://php.net/manual/en/function.zip-entry-filesize.php

get_zip_originalsize(string $filename) : int
Parameters
$filename : string
Return values
int

safecount()

PHP7 has created a little nasty bomb with count throwing erroros on uncountables This is to "fix" this problem

safecount(mixed $element) : int
Parameters
$element : mixed
Tags
author
Return values
int

counted element

switchMSSQLIdentityInsert()

This function switches identity insert on/off for the MSSQL database

switchMSSQLIdentityInsert(string $table, bool $state) : void
Parameters
$table : string

table name (without prefix)

$state : bool

Set to true to activate ID insert, or false to deactivate

resourceExtractFilter()

Helper to filter the contents of a .zip file uploaded into the file manager

resourceExtractFilter(mixed $p_event, mixed &$p_header) : mixed
Parameters
$p_event : mixed
$p_header : mixed

recursive_preg_replace()

Applies preg_replace recursively until $recursion_limit is exceeded or no more replacements are done.

recursive_preg_replace(array<string|int, mixed>|string $pattern, array<string|int, mixed>|string $replacement, array<string|int, mixed>|string $subject[, int $limit = -1 ][, int &$count = 0 ][, int $recursion_limit = 50 ]) : string|array<string|int, mixed>
Parameters
$pattern : array<string|int, mixed>|string
$replacement : array<string|int, mixed>|string
$subject : array<string|int, mixed>|string
$limit : int = -1
$count : int = 0

If specified, this variable will be filled with the total number of replacements done (including all iterations)

$recursion_limit : int = 50

Max number of iterations allowed

Return values
string|array<string|int, mixed>

standardDeviation()

Returns the standard deviation of supplied $numbers

standardDeviation(array<string|int, mixed> $numbers) : float
Parameters
$numbers : array<string|int, mixed>

The numbers to calculate the standard deviation for

Return values
float

isAbsolutePath()

Checks if the specified path is absolute.

isAbsolutePath(string $path) : bool

It handles both Unix and Windows paths.

Parameters
$path : string

the path to be checked

Return values
bool

whether the path is absolute

csvEscape()

Escapes a string for use in a CSV file

csvEscape(string|null $string) : string
Parameters
$string : string|null
Return values
string

        
On this page

Search results