Properties

$_dbinstance

$_dbinstance

Methods

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

db_time()

db_time(int $unixtime, bool $trim)

Convert the supplied unixtime into a database compatible datetime string

Parameters

int $unixtime
bool $trim

Wether or not to trim quotes from the output return string

unix_time()

unix_time(string $string) : int

Given a datatime string convert it to a unix time

Parameters

string $string

The datetime string

Returns

int

get_image_extensions()

get_image_extensions() : string

A convenience method to return the list of allowed image extensions that a user is allowed to upload

Returns

string

get_module()

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)

Parameters

string $module_name
string $version

The desired module version

Returns

object —

The module object. or null

get_cge()

get_cge() : object

A convenience function to get the CGExtensions module object reference

Returns

object —

The CGExtensions module object.

get_mime_type()

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.

Parameters

string $filename
  • The file name.

Returns

string —

The returned mime type.

send_data_and_exit()

send_data_and_exit(string $data, string $content_type, string $filename)

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.

Parameters

string $data

The output data

string $content_type

The output MIME type

string $filename

The output filename

view_file_and_exit()

view_file_and_exit(string $file, string $mime_type, string $filename)

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.

Parameters

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)

send_file_and_exit()

send_file_and_exit(string $file, int $chunksize, 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.

Parameters

string $file

The absolute path to the output file

int $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)

send_ajax_and_exit()

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.

Parameters

mixed $output

get_real_ip()

get_real_ip() : string

Use various methods to return the users real IP address.

including when using a proxy server.

Returns

string

to_bool()

to_bool(mixed $in, boolean $strict) : bool

Given a string input that theoretically represents a boolean value return either true or false.

Parameters

mixed $in

input value

boolean $strict

Whether strict testing should be used.

Returns

bool

get_browser()

get_browser() : \cge_browser

Get the singleton cge_browser object.

Returns

\cge_browser

fgets()

fgets(resource $fh) : string

A platform independent fgets utility.

This method understands MAC (\r) as well as DOS/Unix line endings

Parameters

resource $fh

Returns

string

coalesce()

coalesce() : \The

Return the first non null argument.

This method accepts a variable number of arguments.

Returns

\The —

first non null argument

get_param()

get_param(\hash $params, string $key, mixed $dflt) : 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.

Parameters

\hash $params

The input associative array

string $key

The input key to search for

mixed $dflt

The default value

Returns

mixed —

The value of the element in the array, or the default

src_to_file()

src_to_file(string $src) : string

Given a src specification attempt to resolve it into a filename on the server

algorithm:

  1. Check for an absolute filename
  2. Test if the string starts with the uploads url
    • replace with uploads path
    • check if file exists
  3. Test if the string starts with the root url
    • replace with root path
    • check if file exists
  4. If string starts with /
    • prepend root path
    • check if file exists
  5. assume string is relative to uploads path
    • checkk if file exists
  6. Test if string starts with the ssl url
    • replace with root path
    • check if file exists

Parameters

string $src

the source

Returns

string —

The filename (if possible).

ssl_request()

ssl_request() : bool

Test if the current request is for a secure connection

Returns

bool

file_to_url()

file_to_url(string $file, bool $force_ssl) : 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.

Parameters

string $file

the filename to convert to a URL

bool $force_ssl

Force the output url to use HTTPS

Returns

string

have_enough_memory()

have_enough_memory(int $needed_memory, float $fudge) : bool

An experimental method that attempts to determine if there is enough available PHP memory for a given operation.

Parameters

int $needed_memory

The estimated amount of memory required

float $fudge

The fudge factor (multiplier) used to buffer available memory.

Returns

bool

get_available_memory()

get_available_memory() : int

An experimental method to determine the amount of available PHP memory remaining

Returns

int

clean_input_html()

clean_input_html(string $html) : string

Pretty up, sanitize, and clean user entered html code.

Parameters

string $html

Returns

string

parse_float()

parse_float(string $floatString, string $thousands_sep, string $decimal_pt)

a convenience method to convert a string representing a float value into a float

Parameters

string $floatString

the input string

string $thousands_sep

The thousands separator

string $decimal_pt

The decimal point

encrypt_params()

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.

Parameters

array $params

an associative array

Returns

array

decrypt_params()

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.

Parameters

array $params

an encrypted associative array with at least one element: _d.

Returns

array

done_today()

done_today(string $key) : bool

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.

Parameters

string $key

Returns

bool

swap()

swap(mixed $a, mixed $b)

Swap to variables.

Probably should not be used where cloning may be required.

Parameters

mixed $a
mixed $b

log_exception()

log_exception(\Exception $e)

Dump an exception to the error log.

Parameters

\Exception $e

_newAdodbConnection()

_newAdodbConnection(\cms_config $config)

Parameters

\cms_config $config