FreePBX Utilities Library.

Under /var/www/html/admin/libraries/utility.functions.php , we've got some methods useful they can be used any times.

 

function

Description

function

Description

_bootstrap_parse_hooks()

Helper function to laod hooks for bootstrap_include_hooks()

astdb_get($exclude = array())

None

astdb_put($astdb, $exclude = array())

None

bootstrap_include_hooks($hook_type, $module)

Run bootstrap hooks as provided by module.xml
We currently support hooking at two points: before modules are loaded and after modules are loaded
Before we load ANY modules, we will include all "all_mods" hooks
Before we load an indevidual module, we will load there specifc hook

bytes2string($size)

Returns a rounded string representation of a byte size

check_reload_needed($implicit_grant=false)

Check to see if Apply Changes/Need Reload flag has been set

checkFreeSpace($allowedSpace)

None

compress_framework_css()

None

d($var, $tags = null)

None

dbug()

FreePBX Debugging function

dbug_printtree($dir, $indent = "\t")

Prints an array as a "tree" of data

dbug_write($txt, $check = false)

None

dbugcalltrace()

None

die_freepbx($text, $extended_text="", $type="FATAL")

Throw FreePBX DIE Message

download_file($file, $name = '', $type = '', $force_download = false)

Downloads a file to the browser (i.e. sends the file to the browser)

edit_crontab($remove = '', $add = '')

function edit crontab
short Add/removes stuff rom conrtab
long Use this function to programmatically add/remove data from the crontab
will always run as the asterisk user

error($text,$log=true)

None

fatal($text,$log=true)

None

file_get_contents_url($file_url)

like file_get_contents designed to work with url only, will try
wget if fails or if MODULEADMINWGET set to true. If it detects
failure, will set MODULEADMINWGET to true for future improvements.

fpbx_ami_update($user=false, $pass=false, $writetimeout = false)

Update AMI credentials in manager.conf

fpbx_pdfinfo($pdf)

Get data from a pdf file. Requires pdfinfo

fpbx_which($app)

Returns the absolute path to a system application

freepbx_debug($string, $option='', $filename='')

Log a debug message to a debug file (Depreciated)

freepbx_error_handler($errno, $errstr, $errfile, $errline,  $errcontext)

PHP: Hypertext Preprocessor

freepbx_filesize($file)

Return semi-accurate filesize for files

freepbx_filetype($file)

Check filetype of files

freepbx_log($level, $message)

FreePBX Logging facility to FILE or syslog

freepbx_log_security($txt)

Log a message to the freepbx security file

freepbxGetSanitizedRequest($definition = FILTER_SANITIZE_STRING, $add_empty = true)

Use filter_input_array
The filter extension is enabled by default as of PHP 5.2.0. To disable the filter extension, use --disable-filter .
Before PHP 5.2 an experimental PECL extension was used, however, the PECL version is no longer recommended or updated.

generate_message_banner($message,$type='info',$details=array(),$link='',$closeable = false)

Generate Message Banner(s)

get_framework_version($cached=true)

Get the FreePBX/Framework Version (Depreciated in favor of getversion)

getCpuCount()

None

getSystemMemInfo()

None

getversion($cached=true)

Get the FreePBX/Framework Version

IsAsteriskSupported($version)

None

json_print_pretty($json, $indent = "\t")

this function can print a json object in a "pretty"

needreload()

Tell the user we need to apply changes and reload Asterisk

out($text,$log=true)

None

outn($text,$log=true)

None

rrmdir($dir)

Recursively remove a directory

sanitize_outbound_callerid($cid)

None

scandirr($dir, $absolute = false)

Function scandirr scans a directory just like scandir(), only recursively
returns a hierarchical array representing the directory structure

string2bytes($str, $type = '')

Returns a rounded byte size representation of a string

varsub($string, $del = '$')

do variable substitution

version_compare_freepbx($version1, $version2, $op = null)

version_compare that works with FreePBX version numbers

version_min($origin, $list)

None

Return to Documentation Home I Return to Sangoma Support