Functions

Function Description
arrayToXML Turns a PHP array into an XML string.
arrayFilterRecursive Recursively filters an array.
classAutoLoader Internal function to automatically load module classes as needed.
cleanFile Makes sure that a file path doesn't contain abusive characters (i.e. ../)
colorMesh Returns a color a % of the way between two colors.
copyDirectory Copies a directory and sets writable permissions.
copyFile Copies a file into a directory, even if that directory doesn't exist yet.
cURL Posts to a given URL and returns the response.
currentURL Return the current active URL with correct protocall and port
dateFormat Formats a date that originates in the config defined date format into another.
dateFromOffset Returns a formatted date from a date and an offset.
deleteDirectory Deletes a directory including everything in it.
describeTable Gives in depth information about a MySQL table's structure and keys.
directoryContents Returns a directory's files and subdirectories (with their files) in a flat array with file paths.
formatBytes Formats bytes into larger units to make them more readable.
formatCSS3 Replaces CSS3 delcarations with vendor appropriate ones to reduce CSS redundancy.
formatVendorPrefixes A preg_replace function for transforming a standard CSS3 entry into a vendor prefixed string.
geocodeAddress Returns a latitude and longitude for a given address.
getAvailableFileName Gets a web safe available file name in a given directory.
getCookie Gets a cookie set by setCookie and decodes it.
getFieldSelectOptions Get the <select> options of all the fields in a table.
getTableSelectOptions Get the <select> options for all of tables in the database excluding bigtree_ prefixed tables.
getIsSSL Returns whether BigTree believes it's being served over SSL or not.
globalizeArray Globalizes all the keys of an array into global variables without compromising super global ($_) variables.
globalizeArrayRecursion Used by globalizeArray for recursion.
globalizeGETVars Globalizes all the $_GET variables without compromising $_ variables.
globalizePOSTVars Globalizes all the $_POST variables without compromising $_ variables.
gravatar Returns a properly formatted gravatar url.
isDirectoryWritable Extend's PHP's is_writable to support directories that don't exist yet.
isExternalLink Check if URL is external, relative to site root
json Encodes a variable as JSON. Uses pretty print if available. Optionally escapes for SQL.
makeDirectory Makes a directory (and all applicable parent directories).
moveFile Moves a file into a directory, even if that directory doesn't exist yet.
nextSQLColumnDefinition Return the next SQL name definition from a string.
parsedFilesArray Parses the $_FILES array and returns an array more like a normal $_POST array.
path Get the proper path for a file based on whether a custom override exists.
pathInfo Wrapper for PHP's pathinfo to make sure it supports returning "filename"
phpDateTojQuery Converts a PHP date() format to jQuery date picker format.
placeholderImage Generates placeholder image data.
postMaxSize Returns in bytes the maximum size of a POST.
prefixFile Prefixes a file name with a given prefix.
putFile Writes data to a file, even if that directory for the file doesn't exist yet.
randomString Returns a random string.
redirect Simple URL redirect via header with proper code #
relativeTime Turns a timestamp into "… hours ago" formatting.
remoteIP Returns the remote user's IP address (works with load balancers).
route Returns the proper file to include based on existence of subdirectories or .php files with given route names.
runningAsSU Checks if the current script is running as the owner of the script.
runParser Evaluates code in a function scope with $item and $value
safeEncode Modifies a string so that it is safe for display on the web (tags and quotes modified for usage inside attributes) without double-encoding.
sendEmail Sends an email using PHPMailer
setCookie Sets a site-wide cookie with support for arrays.
setDirectoryPermissions Sets writable permissions for a whole directory.
setPermissions Checks to see if the current user the web server is running as is the owner of the current script.
tableCompare Returns a list of SQL commands required to turn one table into another.
tableContents Returns an array of INSERT statements for the rows of a given table.
tableExists Determines whether a SQL table exists.
touchFile touch()s a file even if the directory for it doesn't exist yet.
translateArray Steps through an array and creates internal page links for all parts of it.
trimLength A smarter version of trim that works with HTML.
unformatBytes Formats a string of kilobytes / megabytes / gigabytes back into bytes.
untranslateArray Steps through an array and creates hard links for all internal page links.
unzip Unzips a file.
uploadMaxFileSize Returns Apache's max file size value for use in forms.
urlExists Attempts to connect to a URL using cURL.

arrayToXML

Turns a PHP array into an XML string.

Return Value: A string of XML.

static arrayToXML($array, $tab = "")
Parameter Description
$array The array to convert.
$tab Current tab depth (for recursion).

arrayFilterRecursive

Recursively filters an array.

Return Value: A filtered array

static arrayFilterRecursive($array)
Parameter Description
$array A multi-dimensional array

classAutoLoader

Internal function to automatically load module classes as needed.

static classAutoLoader()

cleanFile

Makes sure that a file path doesn't contain abusive characters (i.e. ../)

Return Value: Cleaned up string.

static cleanFile($file)
Parameter Description
$file A file name

colorMesh

Returns a color a % of the way between two colors.

Return Value: A hex value color between the first and second colors.

static colorMesh($first_color, $second_color, $percentage)
Parameter Description
$first_color The first color.
$second_color The second color.
$percentage The percentage between the first color and the second you want to move.

copyDirectory

Copies a directory and sets writable permissions.

Return Value: true if the copy was successful

static copyDirectory($source, $destination)
Parameter Description
$source The location of the directory to copy.
$destination The new folder location.

copyFile

Copies a file into a directory, even if that directory doesn't exist yet.

Return Value: true if the copy was successful, false if the directories were not writable or the source was not readable.

static copyFile($from, $to)
Parameter Description
$from The current location of the file.
$to The location of the new copy.

cURL

Posts to a given URL and returns the response.
Wrapper for cURL.

Return Value: The string response from the URL.

static cURL($url, $post = false, $options = [], $strict_security = false, $output_file = false)
Parameter Description
$url The URL to retrieve / POST to.
$post A key/value pair array of things to POST (optional).
$options A key/value pair of extra cURL options (optional).
$strict_security Force SSL verification of the host and peer if true (optional, defaults to false).
$output_file A file location to dump the output of the request to (optional, replaces return value).

currentURL

Return the current active URL with correct protocall and port

static currentURL($port = false)
Parameter Description
$port Whether to return the port for connections not on port 80 (defaults to false)

dateFormat

Formats a date that originates in the config defined date format into another.

Return Value: A date string or false if date parsing failed

static dateFormat($date, $format = "Y-m-d H:i:s")
Parameter Description
$date Date (in any format that strtotime understands or a unix timestamp)
$format Format (in any format that PHP's date function understands, defaults to Y-m-d H:i:s)

dateFromOffset

Returns a formatted date from a date and an offset.
e.g. "January 1, 2015" and "2 months" returns "2015-03-01 00:00:00"

Return Value: A date string

static dateFromOffset($start_date, $offset, $format = "Y-m-d H:i:s")
Parameter Description
$start_date Date to start at (in any format that strtotime understands or a unix timestamp)
$offset Offset (in any "relative" PHP time format)
$format Format for returned date (in any format that PHP's date function understands, defaults to Y-m-d H:i:s)

deleteDirectory

Deletes a directory including everything in it.

Return Value: true if successful

static deleteDirectory($dir)
Parameter Description
$dir The directory to delete.

describeTable

Gives in depth information about a MySQL table's structure and keys.

Return Value: An array of table information.

static describeTable($table)
Parameter Description
$table The table name.

directoryContents

Returns a directory's files and subdirectories (with their files) in a flat array with file paths.

Return Value: Returns false if the directory cannot be read.

static directoryContents($directory, $recursive = true, $extension = false, $include_git = false)
Parameter Description
$directory The directory to search
$recursive Set to false to not recurse subdirectories (defaults to true).
$extension Limit the results to a specific file extension (defaults to false).
$include_git .git and .gitignore will be ignored unless set to true (defaults to false).

formatBytes

Formats bytes into larger units to make them more readable.

Return Value: A string with the number of bytes in kilobytes, megabytes, or gigabytes.

static formatBytes($size)
Parameter Description
$size The number of bytes.

formatCSS3

Replaces CSS3 delcarations with vendor appropriate ones to reduce CSS redundancy.

Return Value: A string of CSS with vendor prefixes.

static formatCSS3($css)
Parameter Description
$css CSS string.

formatVendorPrefixes

A preg_replace function for transforming a standard CSS3 entry into a vendor prefixed string.

Return Value: Replaced string.

static formatVendorPrefixes($data)
Parameter Description
$data preg data

geocodeAddress

Returns a latitude and longitude for a given address.
This method is deprecated and exists only for backwards compatibility (BigTreeGeocoding should be used directly).

Return Value: An associative array with "latitude" and "longitude" keys (or false if geocoding failed).

static geocodeAddress($address)
Parameter Description
$address The address to geocode.

getAvailableFileName

Gets a web safe available file name in a given directory.

Return Value: An available, web safe file name.

static getAvailableFileName($directory, $file, $prefixes = [])
Parameter Description
$directory The destination directory.
$file The desired file name.
$prefixes A list of file prefixes that also need to be accounted for when checking file name availability.

getCookie

Gets a cookie set by setCookie and decodes it.

static getCookie($id)
Parameter Description
$id The id of the set cookie

getFieldSelectOptions

Get the <select> options of all the fields in a table.

static getFieldSelectOptions($table, $default = "", $sorting = false)
Parameter Description
$table The table to draw the fields for.
$default The currently selected value.
$sorting Whether to duplicate fields into "ASC" and "DESC" versions.

getTableSelectOptions

Get the <select> options for all of tables in the database excluding bigtree_ prefixed tables.

static getTableSelectOptions($default = false)
Parameter Description
$default The currently selected value.

getIsSSL

Returns whether BigTree believes it's being served over SSL or not.

static getIsSSL()

globalizeArray

Globalizes all the keys of an array into global variables without compromising super global ($_) variables.
Optionally runs a list of functions (passed in after the array) on the data.

static globalizeArray($array, $functions)
Parameter Description
$array An array with key/value pairs.
$functions Pass in additional arguments to run functions (i.e. "htmlspecialchars") on the data

globalizeArrayRecursion

Used by globalizeArray for recursion.

static globalizeArrayRecursion()

globalizeGETVars

Globalizes all the $_GET variables without compromising $_ variables.
Optionally runs a list of functions passed in as arguments on the data.

static globalizeGETVars($functions)
Parameter Description
$functions Pass in additional arguments to run functions (i.e. "htmlspecialchars") on the data

globalizePOSTVars

Globalizes all the $_POST variables without compromising $_ variables.
Optionally runs a list of functions passed in as arguments on the data.

static globalizePOSTVars($functions)
Parameter Description
$functions Pass in additional arguments to run functions (i.e. "htmlspecialchars") on the data

gravatar

Returns a properly formatted gravatar url.

static gravatar($email, $size = 56, $default = false, $rating = "g")
Parameter Description
$email User's email address.
$size Image size; defaults to 56
$default Default profile image; defaults to BigTree icon
$rating Defaults to "g" (options include "g", "pg", "r", "x")

isDirectoryWritable

Extend's PHP's is_writable to support directories that don't exist yet.

Return Value: true if the directory exists and is writable or could be created, otherwise false.

static isDirectoryWritable($path)
Parameter Description
$path The path to check the writable status of.

json

Encodes a variable as JSON. Uses pretty print if available. Optionally escapes for SQL.

Return Value: A JSON encoded string.

static json($var, $sql = false)
Parameter Description
$var Variable to JSON encode.
$sql Whether to SQL escape the JSON (defaults to false).

makeDirectory

Makes a directory (and all applicable parent directories).
Sets permissions to 777.

static makeDirectory($directory)
Parameter Description
$directory The full path to the directory to be made.

moveFile

Moves a file into a directory, even if that directory doesn't exist yet.

Return Value: true if the move was successful, false if the directories were not writable.

static moveFile($from, $to)
Parameter Description
$from The current location of the file.
$to The location of the new copy.

nextSQLColumnDefinition

Return the next SQL name definition from a string.

Return Value: A string.

static nextSQLColumnDefinition($string)
Parameter Description
$string A string with the name definition being terminated by a single `

parsedFilesArray

Parses the $_FILES array and returns an array more like a normal $_POST array.

Return Value: A more sensible array, or a piece of that sensible array if "part" is set.

static parsedFilesArray($part = false)
Parameter Description
$part (Optional) The key of the file tree to return.

path

Get the proper path for a file based on whether a custom override exists.

Return Value: Hard file path to a custom/ (preferred) or core/ file depending on what exists.

static path($file)
Parameter Description
$file File path relative to either core/ or custom/

pathInfo

Wrapper for PHP's pathinfo to make sure it supports returning "filename"

Return Value: Everything PHP's pathinfo() returns (with "filename" even when PHP doesn't support it).

static pathInfo($file)
Parameter Description
$file The full file path.

phpDateTojQuery

Converts a PHP date() format to jQuery date picker format.

Return Value: jQuery date picker formatting string.

static phpDateTojQuery($format)
Parameter Description
$format PHP date() formatting string

placeholderImage

Generates placeholder image data.

Return Value: Nothing; Renders a placeholder image

static placeholderImage($width, $height, $bg_color = false, $text_color = false, $icon_path = false, $text_string = false)
Parameter Description
$width The width of desired image
$height The height of desired image
$bg_color The background color; must be full 6 charachter hex value
$text_color The text color; must be full 6 charachter hex value
$icon_path Image to render, disables text rendering, must be gif, jpeg, or png
$text_string Text to render; overrides default dimension display

postMaxSize

Returns in bytes the maximum size of a POST.

static postMaxSize()

prefixFile

Prefixes a file name with a given prefix.

Return Value: The full path or file name with a prefix appended to the file name.

static prefixFile($file, $prefix)
Parameter Description
$file A file name or full file path.
$prefix The prefix for the file name.

putFile

Writes data to a file, even if that directory for the file doesn't exist yet.
Sets the file permissions to 777 if the file did not exist.

Return Value: true if the move was successful, false if the directories were not writable.

static putFile($file, $contents)
Parameter Description
$file The location of the file.
$contents The data to write.

randomString

Returns a random string.

Return Value: A random string.

static randomString($length = 8, $seeds = 'alphanum')
Parameter Description
$length The number of characters to return.
$seeds The seed set to use ("alpha" for lowercase letters, "numeric" for numbers, "alphanum" for uppercase letters and numbers, "hexidec" for hexidecimal)

redirect

Simple URL redirect via header with proper code #

static redirect($url = false, $code = ["302"])
Parameter Description
$url The URL to redirect to.
$code The status code of redirect, defaults to normal 302 redirect.

relativeTime

Turns a timestamp into "… hours ago" formatting.

Return Value: A string describing how long ago the passed time was.

static relativeTime($time)
Parameter Description
$time A date/time stamp understandable by strtotime

remoteIP

Returns the remote user's IP address (works with load balancers).

Return Value: An IP address

static remoteIP()

route

Returns the proper file to include based on existence of subdirectories or .php files with given route names.
Used by the CMS for routing ajax and modules.

Return Value: An array with the first element being the file to include and the second element being an array containing extraneous routes from the end of the path.

static route($directory, $path)
Parameter Description
$directory Root directory to begin looking in.
$path An array of routes.

runningAsSU

Checks if the current script is running as the owner of the script.
Useful for determining whether you need to 777 a file you're creating.

Return Value: true if PHP is running as the user that owns the file

static runningAsSU()

runParser

Evaluates code in a function scope with $item and $value
Used mostly internally in the admin for parsers.

Return Value: Modified $value

static runParser($item, $value, $code)
Parameter Description
$item Full array of data
$value The value to be manipulated and returned
$code The code to be run in eval()

safeEncode

Modifies a string so that it is safe for display on the web (tags and quotes modified for usage inside attributes) without double-encoding.
Ensures that other html entities (like &hellip;) turn into UTF-8 characters before encoding.
Only to be used when your website's character set is UTF-8.

Return Value: Encoded string.

static safeEncode($string)
Parameter Description
$string String to encode

sendEmail

Sends an email using PHPMailer

Return Value: true if email is sent, otherwise false.

static sendEmail($to, $subject, $html, $text = "", $from = false, $return = false, $cc = false, $bcc = false, $headers = [], $ = [])
Parameter Description
$to String or array of recipient email address(es)
$subject Subject line text
$html HTML Email Body
$text Text Email Body
$from From email address
$return Return email address (if different than from)
$cc String or array of carbon copy email address(es)
$bcc String or array of blind carbon copy email address(es)
$headers Key/value pair array of extra headers
$

setCookie

Sets a site-wide cookie with support for arrays.
Cookies set by setCookie should be retrieved via getCookie (all values are JSON encoded).

static setCookie($id, $value, $expiration)
Parameter Description
$id The cookie identifier
$value The value to set for the cookie
$expiration Cookie expiration time (in seconds since UNIX epoch) or a string value compatible with strtotime (defaults to session expiration)

setDirectoryPermissions

Sets writable permissions for a whole directory.
If the web server is not running as the owner of the current script, permissions will be 777.

static setDirectoryPermissions($location)
Parameter Description
$location The directory to set permissions on.

setPermissions

Checks to see if the current user the web server is running as is the owner of the current script.
If they are not the same user, the file/directory is given a 777 permission so that the script owner can still manage the file.

static setPermissions($location)
Parameter Description
$location The file or directory to set permissions on.

tableCompare

Returns a list of SQL commands required to turn one table into another.

Return Value: An array of SQL calls to perform to turn Table A into Table B.

static tableCompare($table_a, $table_b)
Parameter Description
$table_a The table that is being translated
$table_b The table that the first table will become

tableContents

Returns an array of INSERT statements for the rows of a given table.
The INSERT statements will be binary safe with binary columns requested in hex.

Return Value: An array.

static tableContents($table)
Parameter Description
$table Table to pull data from.

tableExists

Determines whether a SQL table exists.

Return Value: true if table exists, otherwise false.

static tableExists($table)
Parameter Description
$table The table name.

touchFile

touch()s a file even if the directory for it doesn't exist yet.

static touchFile($file)
Parameter Description
$file The file path to touch.

translateArray

Steps through an array and creates internal page links for all parts of it.

Return Value: An array with internal page links encoded.

static translateArray($array)
Parameter Description
$array The array to process.

trimLength

A smarter version of trim that works with HTML.

Return Value: A string trimmed to the proper number of characters.

static trimLength($string, $length)
Parameter Description
$string A string of text or HTML.
$length The number of characters to trim to.

unformatBytes

Formats a string of kilobytes / megabytes / gigabytes back into bytes.

Return Value: The number of bytes.

static unformatBytes($size)
Parameter Description
$size The string of (kilo/mega/giga)bytes.

untranslateArray

Steps through an array and creates hard links for all internal page links.

Return Value: An array with internal page links decoded.

static untranslateArray($array)
Parameter Description
$array The array to process.

unzip

Unzips a file.

static unzip($file, $destination)
Parameter Description
$file Location of the file to unzip
$destination The full path to unzip the file's contents to.

uploadMaxFileSize

Returns Apache's max file size value for use in forms.

Return Value: The integer value for setting a form's MAX_FILE_SIZE.

static uploadMaxFileSize()

urlExists

Attempts to connect to a URL using cURL.

Return Value: true if it can connect, false if connection failed.

static urlExists($url)
Parameter Description
$url The URL to connect to.