get_db()
get_db() : \adodb
A convenience function to get an adodb object that supports exceptions.
Note: This function creates a new database abstraction object.
Returns
\adodb —object
A set of high level convenience methods.
db_time(integer $unixtime, boolean $trim = true)
Convert the supplied unixtime into a database compatible datetime string
| integer | $unixtime | |
| boolean | $trim | Wether or not to trim quotes from the output return string |
| None found |
unix_time(string|null $string = null) : integer
Given a datatime string convert it to a unix time
| string|null | $string | The datetime string |
| None found |
get_image_extensions() : string
A convenience method to return the list of allowed image extensions that a user is allowed to upload
| None found |
get_module(string $module_name = '', string $version = '') : object
A quick wrapper around cms_utils::get_module that will try to use a module name saved in tmpdata (the module name is stored in tmpdata in each request, for CGExtensions derived modules)
| string | $module_name | |
| string | $version | The desired module version |
The module object. or null
| None found |
get_cge() : object
A convenience function to get the CGExtensions module object reference
The CGExtensions module object.
| None found |
get_mime_type(string $filename) : string
Given a file name, return it's mime type
Requires the fileinfo php extension (which is included by default since PHP 5.3) Throws an exception if the fileinfo extension is not available.
| string | $filename |
|
The returned mime type or null
| None found |
send_data_and_exit(string $data, string $content_type = 'text/plain', string $filename = 'report.txt')
A convenience method to send a text file (like a CSV file) to the browser and exit This is a convenience method. It also handles clearing any data that has already been sent to output buffers.
| string | $data | The output data |
| string | $content_type | The output MIME type |
| string | $filename | The output filename |
| None found |
view_file_and_exit(string $file, string $mime_type = null, string $filename = null)
A convenience method to view a file in the browser.
This is a convenience method. It also handles clearing any data that has already been sent to output buffers.
| string | $file | The absolute path to the output file |
| string | $mime_type | The output mime type |
| string | $filename | The output filename (suggested to the browser) |
| None found |
send_file_and_exit(string $file, integer $chunksize = 65535, string $mime_type = '', string $filename = '')
A convenience method to download a file to the browser, and then exit the current request This method is useful when the user has requested to download a large file.
This is a convenience method. It also handles clearing any data that has already been sent to output buffers.
| string | $file | The absolute path to the output file |
| integer | $chunksize | The amount of data to read from the file at one time |
| string | $mime_type | The output mime type |
| string | $filename | The output filename (suggested to the browser) |
| None found |
send_ajax_and_exit(mixed $output)
Given an output array or object, encode it to json, and exit.
This is a convenience method. It also handles clearing any data that has already been sent to output buffers.
| mixed | $output |
| None found |
get_real_ip() : string
Use various methods to return the users real IP address.
including when using a proxy server.
| None found |
to_bool(mixed $in, boolean $strict = FALSE) : boolean
Given a string input that theoretically represents a boolean value return either true or false.
| mixed | $in | input value |
| boolean | $strict | Whether strict testing should be used. |
| None found |
get_browser() : \cge_browser
Get the singleton cge_browser object.
| None found |
fgets(resource $fh) : string
A platform independent fgets utility.
This method understands MAC (\r) as well as DOS/Unix line endings
| resource | $fh |
or null
| None found |
coalesce() : \The
Return the first non null argument.
This method accepts a variable number of arguments.
first non null argument
| None found |
get_param(\hash $params, string $key, mixed $dflt = null) : mixed
Given an associative array, extract the value of one key, with a default.
If the key does not exist in the array
| \hash | $params | The input associative array |
| string | $key | The input key to search for |
| mixed | $dflt | The default value |
The value of the element in the array, or the default
| None found |
get_empty_param(\hash $params, string $key, mixed $dflt = null) : mixed
Given an associative array, extract the value of one key, with a default.
If the key does not exist in the array, or it's value is empty, then the default is used.
| \hash | $params | The input associative array |
| string | $key | The input key to search for |
| mixed | $dflt | The default value |
The value of the element in the array, or the default
| None found |
src_to_file(string $src) : string
Given a src specification attempt to resolve it into a filename on the server
algorithm:
| string | $src | the source |
The filename (if possible).
| None found |
ssl_request() : boolean
Test if the current request is for a secure connection
| None found |
file_to_url(string $file, boolean $force_ssl = FALSE) : string
Convert a filename to a URL.
If an absolute path is specified tests are done to compare the input to the image uploads path, the uploads path or the root path of the system. If a relative URL path is passed a file relative to the root url is assumed.
| string | $file | the filename to convert to a URL |
| boolean | $force_ssl | Force the output url to use HTTPS |
or null
| None found |
have_enough_memory(integer $needed_memory, float $fudge = 2.0) : boolean
An experimental method that attempts to determine if there is enough available PHP memory for a given operation.
| integer | $needed_memory | The estimated amount of memory required |
| float | $fudge | The fudge factor (multiplier) used to buffer available memory. |
| None found |
get_available_memory() : integer
An experimental method to determine the amount of available PHP memory remaining
| None found |
clean_input_html(string $html) : string
Pretty up, sanitize, and clean user entered html code.
| string | $html |
| None found |
parse_float(string $floatString, string $thousands_sep = null, string $decimal_pt = null)
a convenience method to convert a string representing a float value into a float
| string | $floatString | the input string |
| string | $thousands_sep | The thousands separator |
| string | $decimal_pt | The decimal point |
| None found |
encrypt_params(array $params) : array
A utility function to encrypt parameters for passing through different URL's.
This method accepts a parameter array, encrypts it, and returns a parameter array with a single element: _d.
| array | $params | an associative array |
| None found |
decrypt_params(array $params) : array
A utility function to decrypt previously encrypted parameters.
This method accepts a parameter array (the output from it's companion method) and decrypts the input.
| array | $params | an encrypted associative array with at least one element: _d. |
| None found |
done_today(string $key) : boolean
A convenience function to assist in doing certain tasks only once per day.
This method will convert the key into a preference, and then check the value of that preference if it is more than 24 hours since the last time this method was called for this preference then the value of the preference is updated to the current time and FALSE is returned. Otherwise TRUE is returned.
| string | $key |
| None found |
swap(mixed $a, mixed $b)
Swap to variables.
Probably should not be used where cloning may be required.
| mixed | $a | |
| mixed | $b |
| None found |
log_exception(\Exception $e)
Dump an exception to the error log.
| \Exception | $e |
| None found |
find_image_thumbnail(string $filename) : string|null
Given a thumbnail, return the path to the thumbnail if it exists.
| string | $filename |
| None found |
create_image_thumbnail(string $filename) : string|null
A convenience function to generate a standardized thumbnail for an image.
| string | $filename | The complete path to the image file |
The path to the thumbnail file.
| None found |
get_obfuscated_file_url(integer $page_id, string $filename, boolean $download = null) : string
A convenience function to generate a URL that obfuscates a filename, but allows download.
| integer | $page_id | A page id to use for displaying the file. |
| string | $filename | The complete pathname |
| boolean | $download | Whether the file should be forced to download, or whether the browser can handle it |
A url that allows view or download of the image, but obfuscates the file name and path.
| None found |
create_csrf_inputs() : string
Create HTML elements for a form that contain CSRF keys.
this method also stores data in the session for use by the valid_form_csrf() method.
HTML form elements as a string.
| None found |
valid_form_csrf() : true|null
Given variables available in $_POST generated by the create_csrf_inputs() method validate their values with the data stored in the session.
This method will always return true if 'ignore_cge_csrf' is enabled in the config.php
True if the CSRF data in $_POST matches that in the session. Null/fallse otherwise.
| None found |