Functions

Show a helpful access-denied page. Has a login ability if it senses that logging in could curtail the error.

access_denied(\ID_TEXT $class = 'ACCESS_DENIED', string $param = '', boolean $force_login = false
package core

Parameters

$class

\ID_TEXT

The class of error (e.g. PRIVILEGE). This is a language string.

$param

string

The parameteter given to the error message

$force_login

boolean

Force the user to login (even if perhaps they are logged in already)

Try and make an action log entry into a proper link.

actionlog_linkage(\ID_TEXT $type, string $a, string $b, \Tempcode $_a, \Tempcode $_b) : \?array
package core

Parameters

$type

\ID_TEXT

Action type

$a

string

First parameter

$b

string

Second parameter

$_a

\Tempcode

First parameter (cropped)

$_b

\Tempcode

Second parameter (cropped)

Returns

\?arrayPair: first parameter as possible link, second parameter as possible link (null: could not construct a nice link)

Add a zone.

actual_add_zone(\ID_TEXT $zone, \SHORT_TEXT $title, \ID_TEXT $default_page = 'start', \SHORT_TEXT $header_text = '', \ID_TEXT $theme = 'default', \BINARY $require_session = 0, boolean $uniqify = false, string $base_url = '') : \ID_TEXT
package core

Parameters

$zone

\ID_TEXT

Name of the zone

$title

\SHORT_TEXT

The zone title

$default_page

\ID_TEXT

The zones default page

$header_text

\SHORT_TEXT

The header text

$theme

\ID_TEXT

The theme

$require_session

\BINARY

Whether the zone requires a session for pages to be used

$uniqify

boolean

Whether to force the name as unique, if there's a conflict

$base_url

string

The base URL (blank: natural)

Returns

\ID_TEXTThe name

Delete a zone.

actual_delete_zone(\ID_TEXT $zone, boolean $force = false, boolean $skip_afm = false
package core

Parameters

$zone

\ID_TEXT

The name of the zone

$force

boolean

Force, even if it contains pages

$skip_afm

boolean

Whether to skip the AFM because we know it's not needed (or can't be loaded)

Delete a zones database stuff.

actual_delete_zone_lite(\ID_TEXT $zone) 
package core

Parameters

$zone

\ID_TEXT

The name of the zone

Edit a zone.

actual_edit_zone(\ID_TEXT $zone, \SHORT_TEXT $title, \ID_TEXT $default_page, \SHORT_TEXT $header_text, \ID_TEXT $theme, \BINARY $require_session, \ID_TEXT $new_zone, boolean $uniqify = false, boolean $skip_afm = false, string $base_url = '') : \ID_TEXT
package core

Parameters

$zone

\ID_TEXT

The current name of the zone

$title

\SHORT_TEXT

The zone title

$default_page

\ID_TEXT

The zones default page

$header_text

\SHORT_TEXT

The header text

$theme

\ID_TEXT

The theme

$require_session

\BINARY

Whether the zone requires a session for pages to be used

$new_zone

\ID_TEXT

The new name of the zone

$uniqify

boolean

Whether to force the name as unique, if there's a conflict

$skip_afm

boolean

Whether to skip the AFM because we know it's not needed (or can't be loaded)

$base_url

string

The base URL (blank: natural)

Returns

\ID_TEXTThe name

Rename a zone in the database.

actual_rename_zone_lite(\ID_TEXT $zone, \ID_TEXT $new_zone, boolean $dont_bother_with_main_row = false
package core

Parameters

$zone

\ID_TEXT

The old name of the zone

$new_zone

\ID_TEXT

The new name of the zone

$dont_bother_with_main_row

boolean

Whether to assume the main zone row has already been renamed as part of a wider editing operation

Add an IP-ban.

add_ip_ban(\IP $ip, \LONG_TEXT $descrip = '', \?TIME $ban_until = null, boolean $ban_positive = true) : boolean
package core

Parameters

$ip

\IP

The IP address to ban

$descrip

\LONG_TEXT

Explanation for ban

$ban_until

\?TIME

When to ban until (null: no limit)

$ban_positive

boolean

Whether this is a positive ban (as opposed to a cached negative)

Returns

booleanWhether a change actually happened

Add a privilege, and apply it to every usergroup.

add_privilege(\ID_TEXT $section, \ID_TEXT $name, boolean $default = false, boolean $not_even_mods = false
package core

Parameters

$section

\ID_TEXT

The section the privilege is filled under

$name

\ID_TEXT

The codename for the privilege

$default

boolean

Whether this permission is granted to all usergroups by default

$not_even_mods

boolean

Whether this permission is not granted to supermoderators by default (something very sensitive)

Check to see if an addon is installed.

addon_installed(\ID_TEXT $addon, boolean $non_bundled_too = false) : boolean
package core

Parameters

$addon

\ID_TEXT

The module name

$non_bundled_too

boolean

Whether to check non-bundled addons (ones without an addon_registry hook)

Returns

booleanWhether it is

Adjust an image to take into account EXIF rotation.

adjust_pic_orientation(resource $img, \~array $exif) : array
package core

Parameters

$img

resource

GD image resource

$exif

\~array

EXIF details (false: could not load)

Returns

arrayA pair: Adjusted GD image resource, Whether a change was made

Get extended breadcrumbs for the Admin Zone (called by breadcrumbs_get_default_stub).

adminzone_extended_breadcrumbs() : array
package core

Returns

arrayExtra breadcrumbs

Special code to render Admin Zone Comcode pages with special significances.

adminzone_special_cases(\ID_TEXT $codename) 
package core

Parameters

$codename

\ID_TEXT

The page being loaded

Copies a file (NOT a directory) on the open AFM connection.

afm_copy(\PATH $old_path, \PATH $new_path, boolean $world_access) 
package core

Parameters

$old_path

\PATH

The path to the file we are copying.

$new_path

\PATH

The target path.

$world_access

boolean

Whether world access is required for the copy.

Delete a directory over the open AFM connection.

afm_delete_directory(\PATH $basic_path, boolean $recursive = false
package core

Parameters

$basic_path

\PATH

The path to and of the directory we are deleting.

$recursive

boolean

Whether we should recursively delete any child files and directories.

Deletes a file (NOT a directory) on the open AFM connection.

afm_delete_file(\PATH $basic_path) 
package core

Parameters

$basic_path

\PATH

The path to the file we are deleting.

Make a directory over the open AFM connection.

afm_make_directory(\PATH $basic_path, boolean $world_access, boolean $recursive = false
package core

Parameters

$basic_path

\PATH

The path to and of the directory we are making.

$world_access

boolean

Whether world access is required.

$recursive

boolean

Whether we should recursively make any directories that are missing in the given path, until we can make the final directory.

Make a new file over the open AFM connection. Will overwrite if already exists (assuming has access).

afm_make_file(\PATH $basic_path, string $contents, boolean $world_access) 
package core

Parameters

$basic_path

\PATH

The path to the file we are making.

$contents

string

The desired file contents.

$world_access

boolean

Whether world access is required.

Moves a file on the open AFM connection.

afm_move(\PATH $basic_old_path, \PATH $basic_new_path) 
package core

Parameters

$basic_old_path

\PATH

The path to the file we are moving from.

$basic_new_path

\PATH

The target path.

Read a file (not actually over the open AFM connection, but same result: we can do this directly).

afm_read_file(\PATH $path) : string
package core

Parameters

$path

\PATH

The path to the file we are reading.

Returns

stringThe contents of the file.

Sets permissions over the open AFM connection.

afm_set_perms(\PATH $basic_path, boolean $world_access) 
package core

Parameters

$basic_path

\PATH

The path of the file/directory we are setting permissions of.

$world_access

boolean

Whether world access is required.

Given the string content ID get a mapping we could use as a WHERE map.

append_content_select_for_id(array $select, array $cma_info, \?string $table_alias = null
package core

Parameters

$select

array

The ID

$cma_info

array

The info array for the content type

$table_alias

\?string

The table alias (null: none)

Exit if we are running on a Google App Engine application (live or development).

appengine_general_guard() 
package core

Find if we are running on a live Google App Engine application.

appengine_is_live() : boolean
package core

Returns

booleanIf it is running as a live Google App Engine application

Exit if we are running on a live Google App Engine application.

appengine_live_guard() 
package core

If any Comcode substitutions are configured, apply them.

apply_comcode_page_substitutions(string $comcode) 
package core

Parameters

$comcode

string

The Comcode page contents

Apply hashing to some input. To this date, all forum drivers use md5, but some use it differently.

apply_forum_driver_md5_variant(string $data, string $key) : string

This function will pass through the parameters to an equivalent forum_md5 function if it is defined.

package core

Parameters

$data

string

The data to hash (the password in actuality)

$key

string

The string converted member-ID in actuality, although this function is more general

Returns

stringThe hashed data

Apply whatever escaping is requested to the given value.

apply_tempcode_escaping(array $escaped, string $value) : string
package core

Parameters

$escaped

array

A list of escaping to do

$value

string

The string to apply the escapings to

Returns

stringOutput string (you do not need to collect this, as $value is pass-by-reference -- but this is useful for chaining)

Apply whatever escaping is requested to the given value.

apply_tempcode_escaping_inline(array $escaped, string $value) : string
package core

Parameters

$escaped

array

A list of escaping to do

$value

string

The string to apply the escapings to

Returns

stringOutput string

Count how many elements in an array, recursively.

array_count_recursive(array $arr) : integer
package core

Parameters

$arr

array

The array

Returns

integerThe count

Peek at a stack element.

array_peek(array $array, integer $depth_down = 1) : mixed
package core

Parameters

$array

array

The stack to peek in

$depth_down

integer

The depth into the stack we are peaking

Returns

mixedThe result of the peeking

Assign a page refresh to the specified URL.

assign_refresh(mixed $url, float $multiplier = 0.0

This is almost always used before calling the redirect_screen function. It assumes Composr will output a full screen.

package core
sets_output_state

Parameters

$url

mixed

Refresh to this URL (URLPATH or Tempcode URL)

$multiplier

float

Take this many times longer than a 'standard Composr refresh'

Attach a message to the page output.

attach_message(mixed $message, \ID_TEXT $type = 'inform', boolean $put_in_helper_panel = false) : string
package core
sets_output_state
set inform notice warn

Parameters

$message

mixed

The type of special message

$type

\ID_TEXT

The template to use

$put_in_helper_panel

boolean

Whether to put into the helper panel instead of the normal header area

Returns

stringBlank string so it can be chained in the Tempcode compiler. You will rarely want to use this return value. It's kind of a failsafe.

Attach a message showing memory usage.

attach_message_memory_usage(\Tempcode $messages_bottom) 
package core

Parameters

$messages_bottom

\Tempcode

Where to place the message.

Attach a message mentioning how the site is closed.

attach_message_site_closed(\Tempcode $messages_bottom) 
package core

Parameters

$messages_bottom

\Tempcode

Where to place the message.

Attach a message mentioning SU is active.

attach_message_su(\Tempcode $messages_bottom) 
package core

Parameters

$messages_bottom

\Tempcode

Where to place the message.

Attach some extra JavaScript to <head>. Don't use this too commonly, it's not a 'tidy' way of doing things.

attach_to_javascript(mixed $data) 
package core
sets_output_state

Parameters

$data

mixed

JavaScript to attach (Tempcode or string)

Attach some XHTML to the screen header.

attach_to_screen_header(mixed $data) 
package core
sets_output_state

Parameters

$data

mixed

XHTML to attach (Tempcode or string)

Automatically empty caches.

auto_decache(boolean $changed_base_url) 
package core

Parameters

$changed_base_url

boolean

Whether the base URL has just been changed

Called from 'find_id_moniker'. We tried to lookup a moniker, found a hook, but found no stored moniker. So we'll try and autogenerate one.

autogenerate_new_url_moniker(array $ob_info, array $url_parts, \ID_TEXT $zone) : \?string
package core

Parameters

$ob_info

array

The hooks info profile.

$url_parts

array

The URL component map (must contain 'page', 'type', and 'id' if this function is to do anything).

$zone

\ID_TEXT

The URL zone name (only used for Comcode Page URL monikers).

Returns

\?stringThe moniker ID (null: error generating it somehow, can not do it)

Ban the specified IP address.

ban_ip(\IP $ip, \LONG_TEXT $descrip = ''
package core

Parameters

$ip

\IP

The IP address to ban

$descrip

\LONG_TEXT

Explanation for ban

Parse the specified INI file, and get an array of what it found.

better_parse_ini_file(\?PATH $filename, \?string $file = null) : array
package core

Parameters

$filename

\?PATH

The path to the ini file to open (null: given contents in $file instead)

$file

\?string

The contents of the file (null: the file needs opening)

Returns

arrayA map of the contents of the ini files

Find the default caching setting for a block.

block_cache_default(\ID_TEXT $codename) : \ID_TEXT
package core

Parameters

$codename

\ID_TEXT

The block name

Returns

\ID_TEXTThe default caching setting

Shows an HTML page for making block Comcode.

block_helper_script() 
package core

Check to see if a block is installed.

block_installed(\ID_TEXT $block) : boolean
package core

Parameters

$block

\ID_TEXT

The module name

Returns

booleanWhether it is

Convert a parameter set from a an array (for PHP code) to a string (for templates).

block_params_arr_to_str(array $map) : string
package core

Parameters

$map

array

The parameters / acceptable parameter pattern

Returns

stringThe parameters / acceptable parameter pattern, as template safe parameter

Convert a parameter set from a string (for templates) to an array (for PHP code).

block_params_str_to_arr(string $_map, boolean $block_symbol_style = false) : array
package core

Parameters

$_map

string

The parameters / acceptable parameter pattern, as template safe parameter

$block_symbol_style

boolean

Whether to leave in block symbol style (i.e. like {$BLOCK} would take, a list not a map)

Returns

arrayThe parameters / acceptable parameter pattern

Get the brand name.

brand_name() : string
package core

Returns

stringThe brand name

Convert breadcrumb segments to Tempcode breadcrumbs.

breadcrumb_segments_to_tempcode(array $segments, \?mixed $link_to_self_entrypoint = null) : \Tempcode
package core

Parameters

$segments

array

The segments in array format

$link_to_self_entrypoint

\?mixed

Whether we'll be providing a link to where we are currently at (by reference, gets set to false in some circumstances) (null: don't save by reference)

Returns

\TempcodeThe segments in Tempcode0

Put a list of parents in for the breadcrumbs.

breadcrumb_set_parents(array $parents) 
package core
sets_output_state

Parameters

$parents

array

The list of parent entry points (pairs: entry point, title)

Set the current title.

breadcrumb_set_self(mixed $title) 
package core
sets_output_state

Parameters

$title

mixed

The title (Tempcode or string)

Get the Tempcode for the breadcrumbs.

breadcrumbs(boolean $show_self = true) : \Tempcode
package core

Parameters

$show_self

boolean

Whether to show a self segment

Returns

\TempcodeThe breadcrumbs

Get the Tempcode for the default breadcrumbs stub. This isn't entirely a default, because it does work with breadcrumb_set_parents. We refer to it as a default as it is possible to override the whole breadcrumbs environment via the special BREADCRUMBS global variable.

breadcrumbs_get_default_stub(boolean $link_to_self_entrypoint = true) : \Tempcode
package core

Parameters

$link_to_self_entrypoint

boolean

Whether we'll be providing a link to where we are currently at

Returns

\TempcodeThe default breadcrumb stub

See's if the current browser matches some special property code. Assumes users are keeping up on newish browsers (except for IE users, who are 6+)

browser_matches(string $code) : boolean
package core
set android ios wysiwyg windows mac linux odd_os mobile ie ie8 ie8+ ie9 ie9+ gecko safari odd_browser chrome bot simplified_attachments_ui itunes

Parameters

$code

string

The property code

Returns

booleanWhether there is a match

Build a closure function for a compiled template.

build_closure_function(string $myfunc, array $parts) : string
package core

Parameters

$myfunc

string

The function name

$parts

array

An array of lines to be output, each one in PHP format

Returns

stringFinished PHP code

Build a conventional Tempcode object

build_closure_tempcode(integer $type, \ID_TEXT $name, \?array $parameters, \?array $escaping = null) : \Tempcode
package core
set 0 2

Parameters

$type

integer

The type of symbol this is (TC_SYMBOL, TC_LANGUAGE_REFERENCE)

$name

\ID_TEXT

The name of the symbol

$parameters

\?array

Parameters to the symbol (null: none). In same format as expected by ecv.

$escaping

\?array

Escaping for the symbol (null: none)

Returns

\TempcodeTempcode object.

Build a fulltext query WHERE clause from given content.

build_content_where(string $content, boolean $boolean_search, string $boolean_operator, boolean $full_coverage = false) : array
package core
set AND OR

Parameters

$content

string

The search content

$boolean_search

boolean

Whether it's a boolean search

$boolean_operator

string

Boolean operation to use

$full_coverage

boolean

Whether we can assume we require full coverage (i.e. not substring matches)

Returns

arrayA tuple (any SQL component may be blank): The combined where clause SQL, the boolean operator, body where clause SQL, positive where clause SQL, negative where clause SQL

Get hidden fields for a form representing 'keep_x'. If we are having a GET form instead of a POST form, we need to do this. This function also encodes the page name, as we'll always want that.

build_keep_form_fields(\ID_TEXT $page = '', boolean $keep_all = false, \?array $exclude = null) : \Tempcode
package core

Parameters

$page

\ID_TEXT

The page for the form to go to (blank: don't attach)

$keep_all

boolean

Whether to keep all elements of the current URL represented in this form (rather than just the keep_ fields, and page)

$exclude

\?array

A list of parameters to exclude (null: don't exclude any)

Returns

\TempcodeThe builtup hidden form fields

Relay all POST variables for this URL, to the URL embedded in the form.

build_keep_post_fields(\?array $exclude = null) : \Tempcode
package core

Parameters

$exclude

\?array

A list of parameters to exclude (null: exclude none)

Returns

\TempcodeThe builtup hidden form fields

Build a templated list of the given search results, for viewing.

build_search_results_interface(array $results, integer $start, integer $max, string $direction, boolean $general_search = false) : \Tempcode
package core
set ASC DESC

Parameters

$results

array

Search results

$start

integer

Start index

$max

integer

Maximum index

$direction

string

Sort direction

$general_search

boolean

Whether this is a general search, rather than a search for a specific result-type (such as all members)

Returns

\TempcodeInterface

Build up a submitter search clause, taking into account members, authors, usernames, and usergroups.

build_search_submitter_clauses(\?ID_TEXT $member_field_name, \?MEMBER $member_id, \ID_TEXT $author, \?ID_TEXT $author_field_name = null) : \?string
package core

Parameters

$member_field_name

\?ID_TEXT

The field name for member IDs (null: Cannot match against member IDs)

$member_id

\?MEMBER

Member ID (null: Unknown, so cannot search)

$author

\ID_TEXT

Author

$author_field_name

\?ID_TEXT

The field name for authors (null: Cannot match against member IDs)

Returns

\?stringAn SQL fragment (null: block query)

Our sitemap cache table may need bootstrapping for some reason.

build_sitemap_cache_table() 

Normally we build it iteratively.

package core

Build and return a proper URL, from the $vars array.

build_url(array $vars, \ID_TEXT $zone_name = '', \?array $skip = null, boolean $keep_all = false, boolean $avoid_remap = false, boolean $skip_keep = false, string $hash = '') : \Tempcode

Note: URL parameters should always be in lower case (one of the coding standards)

package core

Parameters

$vars

array

A map of parameter names to parameter values. E.g. array('page'=>'example','type'=>'foo','id'=>2). Values may be strings or integers, or Tempcode, or NULL. NULL indicates "skip this". 'page' cannot be NULL.

$zone_name

\ID_TEXT

The zone the URL is pointing to. YOU SHOULD NEVER HARD CODE THIS- USE '_SEARCH', '_SELF' (if you're self-referencing your own page) or the output of get_module_zone.

$skip

\?array

Variables to explicitly not put in the URL (perhaps because we have $keepall set, or we are blocking certain keep values). The format is of a map where the keys are the names, and the values are 1. (null: don't skip any)

$keep_all

boolean

Whether to keep all non-skipped parameters that were in the current URL, in this URL

$avoid_remap

boolean

Whether to avoid mod_rewrite (sometimes essential so we can assume the standard URL parameter addition scheme in templates)

$skip_keep

boolean

Whether to skip actually putting on keep_ parameters (rarely will this skipping be desirable)

$hash

string

Hash portion of the URL (blank: none). May or may not start '#' - code will put it on if needed

Returns

\TempcodeThe URL in Tempcode format.

Put a member into a usergroup temporarily / extend such a temporary usergroup membership.

bump_member_group_timeout(\MEMBER $member_id, \GROUP $group_id, integer $num_minutes, boolean $prefer_for_primary_group = false
package core

Parameters

$member_id

\MEMBER

The member going in the usergroup.

$group_id

\GROUP

The usergroup.

$num_minutes

integer

The number of minutes (may be negative to take time away).

$prefer_for_primary_group

boolean

Whether to put the member into as a primary group if this is a new temporary membership (it is recommended to NOT use this, since we don't track the source group and hence on expiry the member is put back to the first default group - but also generally you probably don't want to box yourself in with moving people's primary group, it ties your future flexibility down a lot).

Call a function, with inbuilt on-disk caching support.

cache_and_carry(string $func, array $args) : mixed
package core

Parameters

$func

string

Function to call

$args

array

Arguments to call with

Returns

mixedThe function result

Look up and remember what modules are installed.

cache_module_installed_status() 
package core

Send out the newsletter.

call_user_func_array__long_task(string $plain_title, \?Tempcode $title, \ID_TEXT $hook, \?array $args = null, boolean $run_at_end_of_script = false, boolean $force_immediate = false, boolean $send_notification = true) : \Tempcode
package core

Parameters

$plain_title

string

Title to use for completion notification subject lines

$title

\?Tempcode

Title to use if there is no queueing or a queue message (null: don't return a full screen)

$hook

\ID_TEXT

The task hook

$args

\?array

Arguments for the task (null: no arguments)

$run_at_end_of_script

boolean

Whether to run the task at the end of the script (if it's not going to be put into the task queue)

$force_immediate

boolean

Whether to forcibly bypass the task queue (because we've determined somehow it will be a quick task)

$send_notification

boolean

Whether to send a notification of the task having come out of the queue

Returns

\TempcodeUI (function may not return if the task is immediate and doesn't have a text/html result)

Find whether the database may run GROUP BY unfettered with restrictions on the SELECT'd fields having to be represented in it or aggregate functions

can_arbitrary_groupby() : boolean
package core

Returns

booleanWhether it can

Find if a member can be e-mailed.

can_email_member(\MEMBER $member_id, \?string $server = null, \?integer $port = null, \?string $folder = null, \?string $username = null, \?string $password = null) : \?TIME
package core

Parameters

$member_id

\MEMBER

The member ID.

$server

\?string

The IMAP server hostname (null: use configured).

$port

\?integer

The IMAP port (null: use configured).

$folder

\?string

The IMAP inbox identifier (null: use configured).

$username

\?string

The IMAP username (null: use configured).

$password

\?string

The IMAP password (null: use configured).

Returns

\?TIMELast bounce time (null: not bounced).

Find if we can use the static cache.

can_static_cache() : boolean
package core

Returns

booleanWhether we can

Find if mod_rewrite is in use

can_try_mod_rewrite(boolean $avoid_remap = false) : boolean
package core

Parameters

$avoid_remap

boolean

Whether to explicitly avoid using mod_rewrite. Whilst it might seem weird to put this in as a function parameter, it removes duplicated logic checks in the code.

Returns

booleanWhether mod_rewrite is in use

Filter a path so it runs through a CDN.

cdn_filter(\URLPATH $path) : \URLPATH
package core

Parameters

$path

\URLPATH

Input URL

Returns

\URLPATHOutput URL

Check if a member has permission to delete a specific resource. If it doesn't, an error message is outputted.

check_delete_permission(string $range, \?MEMBER $resource_owner, \?array $cats = null, \?ID_TEXT $page = null
package core
set low mid high cat_low cat_mid cat_high

Parameters

$range

string

The range of permission we are checking to see if they have; these ranges are like trust levels

$resource_owner

\?MEMBER

The member that owns this resource (null: no-one)

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

Check to see if a member has permission to edit an item. If it doesn't, an error message is outputted.

check_edit_permission(string $range, \?MEMBER $resource_owner, \?array $cats = null, \?ID_TEXT $page = null
package core
set low mid high cat_low cat_mid cat_high

Parameters

$range

string

The range of permission we are checking to see if they have; these ranges are like trust levels

$resource_owner

\?MEMBER

The member that owns this resource (null: no-one)

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

Check uploaded file extensions for possible malicious intent, and if some is found, an error is put out, and the hackattack logged.

check_extension(string $name, boolean $skip_server_side_security_check = false, \?string $file_to_delete = null, boolean $accept_errors = false) : boolean
package core

Parameters

$name

string

The filename

$skip_server_side_security_check

boolean

Whether to skip the server side security check

$file_to_delete

\?string

Delete this file if we have to exit (null: no file to delete)

$accept_errors

boolean

Whether to allow errors without dying

Returns

booleanSuccess status

Load up details for the current zone.

check_has_page_access() 
package core

Check an input field isn't 'evil'.

check_input_field_string(string $name, string $val, \?boolean $posted = false
package core

Parameters

$name

string

The name of the parameter

$val

string

The value retrieved

$posted

\?boolean

Whether the parameter is a POST parameter (null: undetermined)

Check the given master password is valid.

check_master_password(\SHORT_TEXT $password_given) : boolean
package core

Parameters

$password_given

\SHORT_TEXT

Given master password

Returns

booleanWhether it is valid

Check we can load the given file, given our memory limit.

check_memory_limit_for(\PATH $file_path, boolean $exit_on_error = true) : boolean
package core

Parameters

$file_path

\PATH

The file path we are trying to load

$exit_on_error

boolean

Whether to exit Composr if an error occurs

Returns

booleanSuccess status

Check a page name doesn't conflict, according to our URL scheme.

check_page_name(\ID_TEXT $zone, \ID_TEXT $page) 
package core

Parameters

$zone

\ID_TEXT

The zone name

$page

\ID_TEXT

The page name

Check a posted field isn't 'evil'.

check_posted_field(string $name, string $val) 
package core

Parameters

$name

string

The name of the parameter

$val

string

The value retrieved

Require presence of a permission for the current member; otherwise exit.

check_privilege(\ID_TEXT $permission, \?array $cats = null, \?MEMBER $member_id = null, \?ID_TEXT $page_name = null
package core

Parameters

$permission

\ID_TEXT

The permission to require

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

$member_id

\?MEMBER

Member to check for (null: current user)

$page_name

\?ID_TEXT

Page name to check for (null: current page)

Do an RBL check on an IP address.

check_rbl(\ID_TEXT $rbl, \IP $user_ip, boolean $we_have_a_result_already = false, boolean $page_level = false) : array
package core

Parameters

$rbl

\ID_TEXT

The RBL domain name/IP (HTTP:BL has a special syntax)

$user_ip

\IP

The IP address to lookup

$we_have_a_result_already

boolean

If true, then no RBL check will happen if the RBL has no scoring, because it can't provide a superior result to what is already known (performance)

$page_level

boolean

Whether this is a page level check (i.e. we won't consider blocks or approval, just ban setting)

Returns

arrayPair: Listed for potential blocking as a ANTISPAM_RESPONSE_* constant, confidence level if attainable (0.0 to 1.0) (else NULL)

Check RBLs to see if we need to block this user.

check_rbls(boolean $page_level = false, \?IP $user_ip = null
package core

Parameters

$page_level

boolean

Whether this is a page level check (i.e. we won't consider blocks or approval, just ban setting)

$user_ip

\?IP

IP address (null: current user's)

Check bandwidth usage against page view ratio for shared hosting.

check_shared_bandwidth_usage(integer $extra) 
package core

Parameters

$extra

integer

The extra bandwidth requested

Check disk space usage against page view ratio for shared hosting.

check_shared_space_usage(integer $extra) 
package core

Parameters

$extra

integer

The extra space in bytes requested

Check to see if a member has permission to edit an item. If it doesn't, an error message is outputted.

check_some_edit_permission(string $range, \?array $cats = null, \?ID_TEXT $page = null
package core
set low mid high cat_low cat_mid cat_high

Parameters

$range

string

The range of permission we are checking to see if they have; these ranges are like trust levels

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

Check the stopforumspam service to see if we need to block this user.

check_stopforumspam(\?string $username = null, \?string $email = null
package core

Parameters

$username

\?string

Check this particular username that has just been supplied (null: none)

$email

\?string

Check this particular email address that has just been supplied (null: none)

Check to see if a member has permission to submit an item. If it doesn't, an error message is outputted.

check_submit_permission(string $range, \?array $cats = null, \?ID_TEXT $page = null
package core
set low mid high cat_low cat_mid cat_high

Parameters

$range

string

The range of permission we are checking to see if they have; these ranges are like trust levels

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

Check the specified text ($a) for banned words.

check_word_filter(string $a, \?ID_TEXT $name = null, boolean $no_die = false, boolean $try_patterns = false, boolean $perm_check = true) : string

If any are found, and the member cannot bypass the word filter, an error message is displayed.

package core

Parameters

$a

string

The sentence to check

$name

\?ID_TEXT

The name of the parameter this is coming from. Certain parameters are not checked, for reasons of efficiency (avoiding loading whole word check list if not needed) (null: don't know param, do not check to avoid)

$no_die

boolean

Whether to avoid dying on fully blocked words (useful if importing, for instance)

$try_patterns

boolean

Whether to try pattern matching (this takes more resources)

$perm_check

boolean

Whether to allow permission-based skipping, and length-based skipping

Returns

string"Fixed" version

Takes the output from the scripts, and check the XHTML for conformance, then echoes the page, plus the webstandards checking results.

check_xhtml_webstandards(string $out, boolean $display_regardless = false, integer $preview_mode = 0, boolean $ret = false) : string
package core
set 0 1 2

Parameters

$out

string

The XHTML to check

$display_regardless

boolean

Display XHTML output regardless of whether there was an error or not

$preview_mode

integer

Whether we are opening up an XHTML-fragment in a preview box (0 means no, 1 means yes, 2 means we are asking for additional manual check information)

$ret

boolean

Whether to return Tempcode

Returns

stringReturned result (won't return it $ret is false)

Check a zone name doesn't conflict, according to our URL scheme.

check_zone_name(\ID_TEXT $zone) 
package core

Parameters

$zone

\ID_TEXT

The zone name

UI to choose a language.

choose_language(\Tempcode $title, boolean $tip = false, boolean $allow_all_selection = false) : mixed
package core

Parameters

$title

\Tempcode

Title for the form

$tip

boolean

Whether to give a tip about edit order

$allow_all_selection

boolean

Whether to add an 'all' entry to the list

Returns

mixedThe UI (Tempcode) or the language to use (string/LANGUAGE_NAME)

Format the specified filesize.

clean_file_size(integer $bytes) : string
package core

Parameters

$bytes

integer

The number of bytes the file has

Returns

stringThe formatted-string file size

Turn an HTML title, which could be complex with images, into a nice simple string we can use in <title> and ;.

clean_html_title(string $title) : string
package core

Parameters

$title

string

The relative (to Composr's base directory) path to the page (e.g. pages/comcode/EN/start.txt)

Returns

stringFixed

Make a block codename look nice

cleanup_block_name(\ID_TEXT $block) : string
package core

Parameters

$block

\ID_TEXT

The raw block codename

Returns

stringA nice human readable version of the name

Convert an ISO date into a timestamp.

cleanup_date(string $date) : array
package core

Parameters

$date

string

The ISO date

Returns

arrayIf only one element, it contains the timestamp. Otherwise it is a pair: (string format, timestamp)

Cleanup some EXIF, to the correct character set.

cleanup_exif(array $metadata) : array
package core

Parameters

$metadata

array

The EXIF data

Returns

arrayCleaned up EXIF data

Handle auto-removal of timed-out members.

cleanup_member_timeouts() 
package core

Declare that an action succeeded - delete safety autosave cookies.

clear_cms_autosave() 
package core

Function to clear old uploads, that are older then 2 days

clear_old_uploads() 
package core

Clear permissions API run-time caching.

clear_permissions_runtime_cache() 
package core

Render the site as closed.

closed_site() 
package core

Evaluate some PHP code to put the result into an expression (code is allowed to have side effects).

closure_eval(string $code, array $parameters) : string
package core

Parameters

$code

string

The code

$parameters

array

Template parameters

Returns

stringResult

Perform a simple loop, that can be inlined in an expression.

closure_loop(array $param, array $args, string $main_function) : string
package core

Parameters

$param

array

The template bound parameters

$args

array

The loop directive parameters

$main_function

string

The loop execution function

Returns

stringResult

Perform a simple loop, that can be inlined in an expression.

closure_while_loop(array $args, array $control_function, array $main_function) : string
package core

Parameters

$args

array

The template bound parameters

$control_function

array

The loop control function

$main_function

array

The loop execution function

Returns

stringResult

Get a cookie value.

cms_admirecookie(string $name, \?string $default = null) : \?string
package core

Parameters

$name

string

The name of the cookie

$default

\?string

The default value (null: just use the value NULL)

Returns

\?stringThe value stored in the cookie (null: the default default)

Deletes a cookie (if it exists), from within Composr's cookie environment.

cms_eatcookie(string $name) : boolean
package core

Parameters

$name

string

The name of the cookie

Returns

booleanThe result of the PHP setcookie command

Find details of where we can save temporary files, taking into account PHP's platform-dependent difficulties.

cms_get_temp_dir() : array
package core

Returns

arrayA tuple: preferred temporary path to save to, whether there's a problem saving in the system path, the system path to save to, the local path to save to.

Split a string into smaller chunks, with utf-8 awareness where possible/required. Can be used to split a string into smaller chunks which is useful for e.g. converting base64_encode output to match RFC 2045 semantics. It inserts end (defaults to "\r\n") every chunklen characters.

cms_mb_chunk_split(string $str, integer $len = 76, string $glue = "\r\n", boolean $force = false) : string
package core

Parameters

$str

string

The input string.

$len

integer

The maximum chunking length.

$glue

string

Split character.

$force

boolean

Whether to force unicode as on.

Returns

stringThe chunked version of the input string.

Convert a string to an array, with utf-8 awareness where possible/required.

cms_mb_str_split(string $str, boolean $force = false) : array
package core

Parameters

$str

string

Input.

$force

boolean

Whether to force unicode as on.

Returns

arrayOutput.

Get string length, with utf-8 awareness where possible/required.

cms_mb_strlen(string $in, boolean $force = false) : integer
package core

Parameters

$in

string

The string to get the length of.

$force

boolean

Whether to force unicode as on.

Returns

integerThe string length.

Make a string lowercase, with utf-8 awareness where possible/required.

cms_mb_strtolower(string $in) : string
package core

Parameters

$in

string

Subject.

Returns

stringResult.

Make a string uppercase, with utf-8 awareness where possible/required.

cms_mb_strtoupper(string $in) : string
package core

Parameters

$in

string

Subject.

Returns

stringResult.

Return part of a string, with utf-8 awareness where possible/required.

cms_mb_substr(string $in, integer $from, \?integer $amount = null, boolean $force = false) : \~string
package core

Parameters

$in

string

The subject.

$from

integer

The start position.

$amount

\?integer

The length to extract (null: all remaining).

$force

boolean

Whether to force unicode as on.

Returns

\~stringString part (false: $start was over the end of the string).

Make a string title-case, with utf-8 awareness where possible/required.

cms_mb_ucwords(string $in) : string
package core

Parameters

$in

string

Subject.

Returns

stringResult.

End a profiling block, for a specified identifier (of your own choosing - but you must have started it with cms_profile_start_for).

cms_profile_end_for(\ID_TEXT $identifier, \?string $specifics = null
package core

Parameters

$identifier

\ID_TEXT

Identifier

$specifics

\?string

Longer details of what happened (e.g. a specific SQL query that ran) (null: none provided)

Find whether profiling is enabled. This may be false due to Composr still starting up, in which case it will be enabled later.

cms_profile_is_enabled() : boolean
package core

Returns

booleanWhether profiling is enabled.

Start a profiling block, for a specified identifier (of your own choosing).

cms_profile_start_for(\ID_TEXT $identifier) 
package core

Parameters

$identifier

\ID_TEXT

Identifier

Create a cookie, inside Composr's cookie environment.

cms_setcookie(string $name, string $value, boolean $session = false, boolean $http_only = false, \?integer $days = null) : boolean
package core

Parameters

$name

string

The name of the cookie

$value

string

The value to store in the cookie

$session

boolean

Whether it is a session cookie (gets removed once the browser window closes)

$http_only

boolean

Whether the cookie should not be readable by JavaScript

$days

\?integer

Days to store (null: default)

Returns

booleanThe result of the PHP setcookie command

Get server environment variables.

cms_srv(string $key) : string
package core

Parameters

$key

string

The variable name

Returns

stringThe variable value ('' means unknown)

Format a local time/date according to locale settings. Combines best features of 'strftime' and 'date'.

cms_strftime(string $format, \?TIME $timestamp = null) : string
package core

Parameters

$format

string

The formatting string.

$timestamp

\?TIME

The timestamp (null: now). Assumed to already be timezone-shifted as required

Returns

stringThe formatted string.

Create file with unique file name, but works around compatibility issues between servers. Note that the file is NOT automatically deleted. You should also delete it using "@unlink", as some servers have problems with permissions.

cms_tempnam(string $prefix) : \~string
package core

Parameters

$prefix

string

The prefix of the temporary file name.

Returns

\~stringThe name of the temporary file (false: error).

Trim some text, supporting removing HTML white-space also.

cms_trim(string $text, boolean $try_hard = true) : string
package core

Parameters

$text

string

Input text.

$try_hard

boolean

Whether to keep doing it, while it changes (if complex mixtures are on the end).

Returns

stringThe result text.

Decode a URL component that was encoded with hackerish_url_encode

cms_url_decode_post_process(\URLPATH $url_part) : \URLPATH
package core

Parameters

$url_part

\URLPATH

The URL to encode

Returns

\URLPATHThe encoded result

Encode a URL component in such a way that it won't get nuked by Apache %2F blocking security and url encoded '&' screwing. The get_param_string function will map it back. Hackerish but necessary.

cms_url_encode(\URLPATH $url_part, \?boolean $consider_rewrite = null) : \URLPATH
package core

Parameters

$url_part

\URLPATH

The URL to encode

$consider_rewrite

\?boolean

Whether we have to consider mod_rewrite (null: don't know, look up)

Returns

\URLPATHThe encoded result

Encode a URL component, as per cms_url_encode but without slashes being encoded.

cms_url_encode_mini(\URLPATH $url_part, \?boolean $consider_rewrite = null) : \URLPATH
package core

Parameters

$url_part

\URLPATH

The URL to encode

$consider_rewrite

\?boolean

Whether we have to consider mod_rewrite (null: don't know, look up)

Returns

\URLPATHThe encoded result

Verify the parameters passed into the *calling* function match the phpdoc specification for that function.

cms_verify_parameters_phpdoc(boolean $dev_only = false

Useful when testing robustness of APIs where the CQC and ocProducts PHP are not suitable. For example, when web APIs are plumbed into ocPortal APIs and you need to ensure the types are coming in correctly.

package core

Parameters

$dev_only

boolean

Whether to only run the checks in dev-mode

Get the major version of your installation.

cms_version() : integer
package core

Returns

integerThe major version number of your installation

Get the minor/patch version of your installation. This changes with each release, including bug fix releases. It generally consists of 'a' or 'a.b', where 'a' increments represent major changes and 'b' increments represent tiny changes or alpha/beta/RC numbering.

cms_version_minor() : string
package core

Returns

stringThe minor/patch version number of your installation (e.g. 0.1 or 1.1 or RC1 or 1.RC1)

Get the general version number of your installation (incorporates major and first [numeric] component of minor version number).

cms_version_number() : float
package core

Returns

floatThe general version number of your installation

Get the full string version of Composr that you are running, in 'pretty' format.

cms_version_pretty() : string

This is (and must be kept) equivalent to get_version_pretty__from_dotted(get_version_dotted())

package core

Returns

stringThe string saying the full Composr version number

Get the timestamp at which this version was released.

cms_version_time() : integer
package core

Returns

integerThe timestamp at which this version was released.

Get the timestamp at which this MAJOR version was released.

cms_version_time_major() : integer
package core

Returns

integerThe timestamp at which this MAJOR version was released.

Require all code relating to the Conversr forum

cns_require_all_forum_stuff() 
package core

Take a list of maps of just one element, and make it into a single map

collapse_1d_complexity(string $key, array $list) : array
package core

Parameters

$key

string

The key of our maps that reside in our map

$list

array

The map of maps

Returns

arrayThe collapsed map

Take a list of maps of just two elements, and make it into a single map

collapse_2d_complexity(string $key, string $value, array $list) : array
package core

Parameters

$key

string

The key key of our maps that reside in our map

$value

string

The value key of our maps that reside in our map

$list

array

The map of maps

Returns

arrayThe collapsed map

Get a route from a known Comcode page back to the declared root of the tree.

comcode_breadcrumbs(\ID_TEXT $the_page, \ID_TEXT $the_zone, \ID_TEXT $root = '', boolean $no_link_for_me_sir = true, integer $jumps = 0) : array
package core

Parameters

$the_page

\ID_TEXT

The Comcode page name

$the_zone

\ID_TEXT

The Comcode page zone

$root

\ID_TEXT

The virtual root

$no_link_for_me_sir

boolean

Whether not to put a link at this point in the navigation tree (usually, because the viewer is already at it)

$jumps

integer

The number of jumps we have gone through so far (cuts out after 10 as a failsafe)

Returns

arrayThe breadcrumbs

Convert a language string that is Comcode to Tempcode, with potential caching in the db.

comcode_lang_string(\ID_TEXT $lang_code) : \Tempcode
package core

Parameters

$lang_code

\ID_TEXT

The language string ID

Returns

\TempcodeThe parsed Comcode

Make some Comcode more readable.

comcode_to_clean_text(string $message_plain, boolean $for_extract = false, \?array $tags_to_preserve = null) : string
package core

Parameters

$message_plain

string

Comcode text to change

$for_extract

boolean

Whether this is for generating an extract that does not need to be fully comprehended (i.e. favour brevity)

$tags_to_preserve

\?array

List of tags to preserve (null: none)

Returns

stringClean text

Compare two IP addresses for potential correlation. Not as simple as equality due to '*' syntax.

compare_ip_address(string $wild, \IP $full) : boolean
package core

Parameters

$wild

string

The general IP address that is potentially wildcarded

$full

\IP

The specific IP address we are checking

Returns

booleanWhether the IP addresses correlate

Compare two IP addresses for potential correlation. Not as simple as equality due to '*' syntax. IP4-only variant

compare_ip_address_ip4(string $wild, array $full_parts) : boolean
package core

Parameters

$wild

string

The general IP address that is potentially wildcarded

$full_parts

array

The exploded parts of the specific IP address we are checking

Returns

booleanWhether the IP addresses correlate

Compare two IP addresses for potential correlation. Not as simple as equality due to '*' syntax. IP6-only variant

compare_ip_address_ip6(string $wild, array $full_parts) : boolean
package core

Parameters

$wild

string

The general IP address that is potentially wildcarded

$full_parts

array

The exploded parts of the specific IP address we are checking

Returns

booleanWhether the IP addresses correlate

Compile a template into a list of appendable outputs, for the closure-style Tempcode implementation.

compile_template(string $data, \ID_TEXT $template_name, \ID_TEXT $theme, \ID_TEXT $lang, boolean $tolerate_errors = false) : array
package core

Parameters

$data

string

The template file contents

$template_name

\ID_TEXT

The name of the template

$theme

\ID_TEXT

The name of the theme

$lang

\ID_TEXT

The language it is for

$tolerate_errors

boolean

Whether to tolerate errors

Returns

arrayA pair: array Compiled result structure, array preprocessable bits (special stuff needing attention that is referenced within the template)

Rebuild the specified caches.

composr_cleanup(\?array $caches = null) : \Tempcode
package core

Parameters

$caches

\?array

The caches to rebuild (null: all)

Returns

\TempcodeAny messages returned

Compress a file, and save with a stem of .gz.

compress_cms_stub_file(\PATH $stub_file) 
package core

Parameters

$stub_file

\PATH

Full path to the file to compress

Update a reference stored in a config option.

config_option_url(\ID_TEXT $name) : \?URLPATH
package core

Parameters

$name

\ID_TEXT

The config option name

Returns

\?URLPATHURL to set the config option (null: no such option exists)

Update a reference stored in a config option.

config_update_value_ref(\SHORT_TEXT $old_setting, \SHORT_TEXT $setting, \ID_TEXT $type) 
package core

Parameters

$old_setting

\SHORT_TEXT

The old value

$setting

\SHORT_TEXT

The name value

$type

\ID_TEXT

The type

Get meta details of a content item

content_get_details(\ID_TEXT $content_type, \ID_TEXT $content_id, boolean $resourcefs_style = false) : array
package core

Parameters

$content_type

\ID_TEXT

Content type

$content_id

\ID_TEXT

Content ID

$resourcefs_style

boolean

Whether to use the content API as resource-fs requires (may be slightly different)

Returns

arrayTuple: title, submitter, content hook info, the content row, URL (for use within current browser session), URL (for use in emails / sharing)

Get the content row of a content item.

content_get_row(\ID_TEXT $content_id, array $cma_info) : \?array
package core

Parameters

$content_id

\ID_TEXT

The content ID

$cma_info

array

The info array for the content type

Returns

\?arrayThe row (null: not found)

Find whether some content is validated.

content_validated(\ID_TEXT $content_type, \ID_TEXT $content_id) : boolean
package core

Parameters

$content_type

\ID_TEXT

Content type

$content_id

\ID_TEXT

Content ID

Returns

booleanWhether it is validated

Convert HTML entities to plain characters for XML conformance.

convert_bad_entities(string $data, string $charset = 'ISO-8859-1') : string
package core

Parameters

$data

string

HTML to convert entities from

$charset

string

The character set we are using for $data (both in and out)

Returns

stringValid XHTML

Find a different content type code from the one had.

convert_composr_type_codes(\ID_TEXT $type_has, \ID_TEXT $type_id, \ID_TEXT $type_wanted) : \ID_TEXT
package core
set addon content_type meta_hook search_hook seo_type_code feedback_type_code permissions_type_code module table
set addon content_type meta_hook search_hook seo_type_code feedback_type_code permissions_type_code module table

Parameters

$type_has

\ID_TEXT

Content type type we know

$type_id

\ID_TEXT

Content type ID we know

$type_wanted

\ID_TEXT

Desired content type

Returns

\ID_TEXTCorrected content type type (blank: could not find)

Find content type info, for a particular content type type we know.

convert_composr_type_codes_multiple(\ID_TEXT $type_has, \ID_TEXT $type_id) : array
package core
set addon content_type meta_hook search_hook seo_type_code feedback_type_code permissions_type_code module table

Parameters

$type_has

\ID_TEXT

Content type type we know

$type_id

\ID_TEXT

Content type ID we know

Returns

arrayContent type info list (blank: could not find)

Performs lots of magic to make sure data encodings are converted correctly. Input, and output too (as often stores internally in UTF or performs automatic dynamic conversions from internal to external charsets).

convert_data_encodings(boolean $known_utf8 = false

Roll on PHP6 that has a true internal UTF string model. For now, anyone who uses UTF will get some (albeit minor) imperfections from PHP's manipulations of the strings.

package core

Parameters

$known_utf8

boolean

Whether we know we are working in UTF-8. This is the case for AJAX calls.

Convert GUIDs to IDs in some text.

convert_guids_to_ids(string $text) : string
package core

Parameters

$text

string

Input text

Returns

stringOutput text

Resize an image to the specified size, but retain the aspect ratio.

convert_image(\URLPATH $from, \PATH $to, integer $width, integer $height, integer $box_width = -1, boolean $exit_on_error = true, \?string $ext2 = null, boolean $using_path = false, boolean $only_make_smaller = true, \?array $thumb_options = null) : boolean
package core

Parameters

$from

\URLPATH

The URL to the image to resize

$to

\PATH

The file path (including filename) to where the resized image will be saved

$width

integer

The maximum width we want our new image to be (-1 means "don't factor this in")

$height

integer

The maximum height we want our new image to be (-1 means "don't factor this in")

$box_width

integer

This is only considered if both $width and $height are -1. If set, it will fit the image to a box of this dimension (suited for resizing both landscape and portraits fairly)

$exit_on_error

boolean

Whether to exit Composr if an error occurs

$ext2

\?string

The file extension to save with (null: same as our input file)

$using_path

boolean

Whether $from was in fact a path, not a URL

$only_make_smaller

boolean

Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images)

$thumb_options

\?array

This optional parameter allows us to specify cropping or padding for the image. See comments in the function. (null: no details passed)

Returns

booleanSuccess

Given a timezone offset, make it into a formal timezone.

convert_timezone_offset_to_formal_timezone(float $offset) : string
package core

Parameters

$offset

float

Timezone offset.

Returns

stringUsers timezone in "boring" format.

Convert some data from one encoding to the internal encoding.

convert_to_internal_encoding(string $data, \?string $input_charset = null, \?string $internal_charset = null) : string
package core

Parameters

$data

string

Data to convert.

$input_charset

\?string

Charset to convert from (null: that read by the last http_download_file call).

$internal_charset

\?string

Charset to convert to (null: current encoding).

Returns

stringConverted data.

Convert a URL to a local file path.

convert_url_to_path(\URLPATH $url) : \?PATH
package core

Parameters

$url

\URLPATH

The value to convert

Returns

\?PATHFile path (null: is not local)

Calculate CRC32 for a file. Based on a function in the PHP docs.

crc32_file(\PATH $filename) : \?integer
package core

Parameters

$filename

\PATH

The file

Returns

\?integerThe CRC (null: error)

Get an HTML selection list for some part of the Sitemap.

create_selection_list(\ID_TEXT $root_page_link, boolean $under_only = false, \?ID_TEXT $default = null, \?array $valid_node_types = null, \?array $valid_selectable_content_types = null, integer $check_permissions_against = 0, \?MEMBER $check_permissions_for = null, boolean $consider_validation = false, \?MEMBER $only_owned = null, boolean $use_compound_list = false, \?mixed $filter_func = null) : \Tempcode
package core

Parameters

$root_page_link

\ID_TEXT

The page-link we are starting from.

$under_only

boolean

Create from under this node, rather than at it.

$default

\?ID_TEXT

Default selection (null: none).

$valid_node_types

\?array

List of node types we will return/recurse-through (null: no limit)

$valid_selectable_content_types

\?array

List of node types we will allow to be selectable (null: no limit)

$check_permissions_against

integer

Check permissions according to this bitmask of possibilities (requiring all in the bitmask to be matched)

$check_permissions_for

\?MEMBER

The member we are checking permissions for (null: current member)

$consider_validation

boolean

Whether to filter out non-validated entries if the $check_permissions_for user doesn't have the privilege to see them AND doesn't own them

$only_owned

\?MEMBER

The member we are only finding owned content of (null: no such limit); nodes leading up to owned content will be shown, but not as selectable

$use_compound_list

boolean

Whether to produce selection IDs as a comma-separated list of all selectable sub-nodes.

$filter_func

\?mixed

Filter function for limiting what rows will be included (null: none).

Returns

\TempcodeList.

Get a nice formatted XHTML listed language file selector for the given language.

create_selection_list_lang_files(\?LANGUAGE_NAME $lang = null) : \Tempcode
package core

Parameters

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

Returns

\TempcodeThe language file selector

Get a nice formatted XHTML listed language selector.

create_selection_list_langs(\?LANGUAGE_NAME $select_lang = null, boolean $show_unset = false) : \Tempcode
package core

Parameters

$select_lang

\?LANGUAGE_NAME

The language to have selected by default (null: uses the current language)

$show_unset

boolean

Whether to show languages that have no language details currently defined for them

Returns

\TempcodeThe language selector

Get a list of zones.

create_selection_list_zones(\?ID_TEXT $sel = null, \?array $no_go = null, \?array $reorder = null, \?TIME $updated_since = null) : \Tempcode
package core

Parameters

$sel

\?ID_TEXT

The zone in the list to select by default (null: use first)

$no_go

\?array

A list of zone to not put into the list (null: none to skip)

$reorder

\?array

A reordering (null: no reordering)

$updated_since

\?TIME

Time from which content must be updated (null: no limit).

Returns

\TempcodeThe list

Set up a new session / Restore an existing one that was lost.

create_session(\MEMBER $member, \BINARY $session_confirmed = 0, boolean $invisible = false) : \ID_TEXT
package core
sets_output_state

Parameters

$member

\MEMBER

Logged in member

$session_confirmed

\BINARY

Whether the session should be considered confirmed

$invisible

boolean

Whether the session should be invisible

Returns

\ID_TEXTNew session ID

Create a zip file.

create_zip_file(array $file_array, boolean $stream = false, boolean $get_offsets = false, \?PATH $outfile_path = null) : mixed
package core

Parameters

$file_array

array

A list of maps (time,data/full_path,name) covering everything to zip up

$stream

boolean

Whether to stream the output direct to the browser

$get_offsets

boolean

Whether to return the tuple

$outfile_path

\?PATH

File to spool into (null: none). $stream will be forced to false

Returns

mixedThe data for the zip file OR a tuple: data, offsets, sizes; will be blank if $stream is true or $outfile_path is not NULL

Exit with a nicely formatted critical error.

critical_error(string $code, \?string $relay = null, boolean $exit = true
package core

Parameters

$code

string

The error message code

$relay

\?string

Relayed additional details (null: nothing relayed)

$exit

boolean

Whether to actually exit

Find if Cron is installed

cron_installed() : boolean
package core

Returns

booleanWhether Cron is installed

Compile a CSS file.

css_compile(\ID_TEXT $active_theme, \ID_TEXT $theme, \ID_TEXT $c, \PATH $fullpath, \PATH $css_cache_path, boolean $minify = true
package core

Parameters

$active_theme

\ID_TEXT

The theme the file is being loaded for

$theme

\ID_TEXT

The theme the file is in

$c

\ID_TEXT

Name of the CSS file

$fullpath

\PATH

Full path to the CSS file

$css_cache_path

\PATH

Full path to where the cached CSS file will go

$minify

boolean

Whether to also do minification

Force a CSS file to be cached.

css_enforce(string $c, \?ID_TEXT $theme = null, \?boolean $minify = null) : string
package core

Parameters

$c

string

The CSS file required

$theme

\?ID_TEXT

The name of the theme (null: current theme)

$minify

\?boolean

Whether to minify (null: read from environment)

Returns

stringThe path to the CSS file in the cache (blank: no file)

Inherit from a CSS file to create a string for a (possibly theme-gen) modified version of that file.

css_inherit(\ID_TEXT $css_file, \ID_TEXT $theme, \ID_TEXT $destination_theme, \?ID_TEXT $seed, boolean $dark, \ID_TEXT $algorithm) : string
package core
set equations hsv

Parameters

$css_file

\ID_TEXT

Source CSS file

$theme

\ID_TEXT

Source theme

$destination_theme

\ID_TEXT

Destination theme

$seed

\?ID_TEXT

Seed (null: do not re-seed)

$dark

boolean

Whether it is a dark theme

$algorithm

\ID_TEXT

The algorithm to use

Returns

stringThe sheet

Minifies stylesheet definitions

css_minify(string $v) : string
package core

Parameters

$v

string

Stylesheet definitions as string

Returns

stringMinified stylesheet definitions

Get Tempcode to tie in (to the HTML, in <head>) all the CSS files that have been required.

css_tempcode(boolean $inline = false, boolean $only_global = false, \?string $context = null, \?ID_TEXT $theme = null) : \Tempcode
package core

Parameters

$inline

boolean

Force inline CSS

$only_global

boolean

Only do global CSS

$context

\?string

HTML context for which we filter (minimise) any CSS we spit out as inline (null: none)

$theme

\?ID_TEXT

The name of the theme (null: current theme)

Returns

\TempcodeThe Tempcode to tie in the CSS files

Find out what script is running.

current_script() : \ID_TEXT
package core

Returns

\ID_TEXTThe script running (usually 'index')

Find the user-ID of the current shared-site install from the accessing URL. This should only ever be called when it is known a shared-site is in operation

current_share_user() : \?ID_TEXT
package core

Returns

\?ID_TEXTThe shared-site install (null: not on one)

Encode a LIKE string comparision fragement for the database system. The pattern is a mixture of characters and ? and % wilcard symbols.

db_encode_like(string $pattern) : string
package core

Parameters

$pattern

string

The pattern

Returns

stringThe encoded pattern

Escape a string so it may be inserted into a query. If SQL statements are being built up and passed using db_query then it is essential that this is used for security reasons. Otherwise, the abstraction layer deals with the situation.

db_escape_string(string $string) : string
package core

Parameters

$string

string

The string

Returns

stringThe escaped string

Assemble part of a WHERE clause for doing full-text search

db_full_text_assemble(string $content, boolean $boolean) : string
package core

Parameters

$content

string

Our match string (assumes "?" has been stripped already)

$boolean

boolean

Whether to do a boolean full text search

Returns

stringPart of a WHERE clause for doing full-text search

Get the ID of the first row in an auto-increment table (used whenever we need to reference the first).

db_get_first_id() : integer
package core

Returns

integerFirst ID used

Find whether expression ordering support is present

db_has_expression_ordering(array $db) : boolean
package core

Parameters

$db

array

A DB connection

Returns

booleanWhether it is

Find whether full-text-search is present

db_has_full_text(array $db) : boolean
package core

Parameters

$db

array

A DB connection

Returns

booleanWhether it is

Find whether subquery support is present

db_has_subqueries(array $db) : boolean
package core

Parameters

$db

array

A DB connection

Returns

booleanWhether it is

Generate SQL for a boolean search.

db_like_assemble(string $content, string $boolean_operator = 'AND', boolean $full_coverage = false) : array
package core
set AND OR

Parameters

$content

string

Boolean search string

$boolean_operator

string

Boolean operator to use

$full_coverage

boolean

Whether we can assume we require full coverage

Returns

arrayA tuple (any SQL component may be blank): The combined where clause SQL, the boolean operator, body where clause SQL, positive where clause SQL, negative where clause SQL

Extract certain fields, including any Tempcode details for them, from a DB table row array.

db_map_restrict(array $row, array $fields) : array
package core

Parameters

$row

array

DB table row.

$fields

array

List of fields to copy through.

Returns

arrayMap of fields.

Encode an SQL statement fragment for a conditional to see if two strings are equal.

db_string_equal_to(\ID_TEXT $attribute, string $compare) : string
package core

Parameters

$attribute

\ID_TEXT

The attribute

$compare

string

The comparison

Returns

stringThe SQL

Encode an SQL statement fragment for a conditional to see if two strings are not equal.

db_string_not_equal_to(\ID_TEXT $attribute, string $compare) : string
package core

Parameters

$attribute

\ID_TEXT

The attribute

$compare

string

The comparison

Returns

stringThe SQL

Remove an item from the general cache (most commonly used for blocks).

decache(mixed $cached_for, \?array $identifier = null, \?MEMBER $member = null
package core

Parameters

$cached_for

mixed

The type of what we are caching (e.g. block name) (ID_TEXT or an array of ID_TEXT, the array may be pairs re-specifying $identifier)

$identifier

\?array

A map of identifiying characteristics (null: no identifying characteristics, decache all)

$member

\?MEMBER

Member to only decache for (null: no limit)

Decrypt data using asymmetric encryption, and the site's private key (as unlocked by the given passphrase).

decrypt_data(string $data, string $passphrase) : string

A fatal error will occur if the passphrase is empty, the key cannot be found, or if decryption fails for whatever reason.

package core

Parameters

$data

string

Data to be decrypted

$passphrase

string

Passphrase to unlock the site's private key

Returns

stringDecrypted data

Delete all the contents of a directory, and any subdirectories of that specified directory (recursively).

deldir_contents(\PATH $dir, boolean $default_preserve = false, boolean $just_files = false
package core

Parameters

$dir

\PATH

The pathname to the directory to delete

$default_preserve

boolean

Whether to preserve files there by default

$just_files

boolean

Whether to just delete files

Delete attachments solely used by the specified hook.

delete_attachments(\ID_TEXT $type, \?object $connection = null
package core

Parameters

$type

\ID_TEXT

The hook

$connection

\?object

The database connection to use (null: standard site connection)

Delete a Composr page.

delete_cms_page(\ID_TEXT $zone, \ID_TEXT $page, \?ID_TEXT $type = null, boolean $use_afm = false
package core

Parameters

$zone

\ID_TEXT

The zone

$page

\ID_TEXT

The page

$type

\?ID_TEXT

The page type (null: Comcode page in Composr's fallback language) [NB: page is deleted in all languages regardless of which is given]

$use_afm

boolean

Whether to use the AFM

Deletes a specified config option permanently from the database.

delete_config_option(\ID_TEXT $name) 
package core

Parameters

$name

\ID_TEXT

The codename of the config option

Find what sessions are expired and delete them, and recover an existing one for $member if there is one.

delete_expired_sessions_or_recover(\?MEMBER $member = null) : \?AUTO_LINK
package core

Parameters

$member

\?MEMBER

User to get a current session for (null: do not try, which guarantees a return result of NULL also)

Returns

\?AUTO_LINKThe session ID we rebound to (null: did not rebind)

Delete the specified language entry from the translation table.

delete_lang(integer $id, \?object $connection = null
package core

Parameters

$id

integer

The ID

$connection

\?object

The database connection to use (null: standard site connection)

Delete a privilege, and every usergroup is then relaxed from the restrictions of this permission.

delete_privilege(\ID_TEXT $name) 
package core

Parameters

$name

\ID_TEXT

The codename of the permission

Delete a session.

delete_session(\ID_TEXT $session) 
package core

Parameters

$session

\ID_TEXT

The new session

Delete an uploaded file from disk, if it's URL has changed (i.e. it's been replaced, leaving a redundant disk file).

delete_upload(string $upload_path, \ID_TEXT $table, \ID_TEXT $field, mixed $id_field, mixed $id, \?string $new_url = null

This MUST be run before the edit/delete operation, as it scans for the existing value to know what is changing.

package core

Parameters

$upload_path

string

The path to the upload directory

$table

\ID_TEXT

The table name

$field

\ID_TEXT

The table field name

$id_field

mixed

The table ID field name, or a map array

$id

mixed

The table ID

$new_url

\?string

The new URL to use (null: deleting without replacing: no change check)

Delete a situational value.

delete_value(\ID_TEXT $name) 
package core

Parameters

$name

\ID_TEXT

The name of the value

Do a smart decache dependency check for the case of multiple files.

dependencies_are_good(array $dep, \TIME $tcp_time) : boolean
package core

Parameters

$dep

array

Dependent files (full file paths)

$tcp_time

\TIME

Time of cache file

Returns

booleanWhether decache is NOT needed

preg_replace callback to de-shout text.

deshout_callback(array $matches) : string
package core

Parameters

$matches

array

Matches

Returns

stringDe-shouted string

Remove Composr's strictness, to help integration of third-party code.

destrictify(boolean $change_content_type = true, boolean $mysql_too = false
package core

Parameters

$change_content_type

boolean

Whether to also set the content type to plain-HTML

$mysql_too

boolean

Whether to destrictify MySQL commands over the Composr database driver

Run after-tests for dev mode, to make sure coding standards are met.

dev_mode_aftertests() 
package core

Echo an error message, and a debug back-trace of the current execution stack. Use this for debugging purposes.

die_html_trace(string $message) 
package core

Parameters

$message

string

An error message

This will create a new Tempcode object that is containing a single specifed directive

directive_tempcode(\ID_TEXT $directive, mixed $content, \?array $parameters = null) : \Tempcode
package core

Parameters

$directive

\ID_TEXT

The ID of the directive to use

$content

mixed

The contents (Tempcode or string)

$parameters

\?array

Directive parameters (null: none)

Returns

\TempcodeA directive Tempcode object

Disable the PHP memory limit. Do not use this carelessly, use it if a screen is a bit fat or in an importer, don't use it assuming memory is infinite.

disable_php_memory_limit() 
package core

Display a time period of seconds in a tidy human-readable way.

display_seconds_period(integer $seconds) : string
package core

Parameters

$seconds

integer

Number of seconds

Returns

stringHuman-readable period.

Display a time period in a tidy human-readable way.

display_time_period(integer $seconds) : string
package core

Parameters

$seconds

integer

Number of seconds

Returns

stringHuman-readable period.

Show results of running a webstandards checking function.

display_webstandards_results(string $out, array $error, boolean $preview_mode = false, boolean $ret = false) : string
package core

Parameters

$out

string

The data that was checked

$error

array

Error information

$preview_mode

boolean

Whether we are opening up an XHTML-fragment in a preview box

$ret

boolean

Whether to return Tempcode

Returns

stringReturned result (won't return it $ret is false)

Get the Tempcode for a div. Similar to paragraph, but may contain more formatting (such as <br />'s)

div(\Tempcode $tempcode, string $guid = '') : \Tempcode
package core

Parameters

$tempcode

\Tempcode

The Tempcode to put into a div

$guid

string

GUID for call

Returns

\TempcodeThe generated div with contents

Get the processed Tempcode for the specified block. Please note that you pass multiple parameters in as an array, but single parameters go in as a string or other flat variable.

do_block(\ID_TEXT $codename, \?array $map = null, \?integer $ttl = null) : \Tempcode
package core

Parameters

$codename

\ID_TEXT

The block name

$map

\?array

The block parameter map (null: no parameters)

$ttl

\?integer

The TTL to use in minutes (null: block default)

Returns

\TempcodeThe generated Tempcode

Takes a string which is a PHP expression over $map (parameter map), and returns a derived identifier.

do_block_get_cache_identifier(mixed $cache_on, \?array $map) : \?LONG_TEXT

We see if we have something cached by looking for a matching identifier.

package core

Parameters

$cache_on

mixed

PHP expression over $map (the parameter map of the block) OR a call_user_func specifier that will return a result (which will be used if caching is really very important, even for Hip Hop PHP)

$map

\?array

The block parameter map (null: no parameters)

Returns

\?LONG_TEXTThe derived cache identifier (null: the identifier is CURRENTLY null meaning cannot be cached)

Get the block object for a given block codename.

do_block_hunt_file(\ID_TEXT $codename, \?array $map = null) : array
package core

Parameters

$codename

\ID_TEXT

The block name

$map

\?array

The block parameter map (null: no parameters)

Returns

arrayA pair: Either the block object, or the string output of a miniblock ; and whether we entered a new security scope

Do a UTF8 conversion on the environmental GET/POST parameters.

do_environment_utf8_conversion(string $from_charset) 
package core

Parameters

$from_charset

string

Charset that was used to encode the environmental data.

Get the Tempcode for an image thumbnail.

do_image_thumb(\URLPATH $url, mixed $caption, boolean $js_tooltip = false, boolean $is_thumbnail_already = true, \?integer $width = null, \?integer $height = null, boolean $only_make_smaller = false) : \Tempcode
package core

Parameters

$url

\URLPATH

The URL to the image thumbnail

$caption

mixed

The caption for the thumbnail (string or Tempcode)

$js_tooltip

boolean

Whether to use a JS tooltip. Forcibly set to true if you pass Tempcode

$is_thumbnail_already

boolean

Whether already a thumbnail (if not, function will make one)

$width

\?integer

Thumbnail width to use (null: default)

$height

\?integer

Thumbnail height to use (null: default)

$only_make_smaller

boolean

Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images)

Returns

\TempcodeThe thumbnail

Get the human-readable form of a language ID, or a language entry from a language INI file.

do_lang(\ID_TEXT $codename, \?mixed $token1 = null, \?mixed $token2 = null, \?mixed $token3 = null, \?LANGUAGE_NAME $lang = null, boolean $require_result = true) : \?mixed
package core

Parameters

$codename

\ID_TEXT

The language ID

$token1

\?mixed

The first token [string or Tempcode] (replaces {1}) (null: none)

$token2

\?mixed

The second token [string or Tempcode] (replaces {2}) (null: none)

$token3

\?mixed

The third token (replaces {3}). May be an array of [of string], to allow any number of additional args (null: none)

$lang

\?LANGUAGE_NAME

The language to use (null: users language)

$require_result

boolean

Whether to cause Composr to exit if the lookup does not succeed

Returns

\?mixedThe human-readable content (null: not found). String normally. Tempcode if Tempcode parameters.

This will create a new Tempcode object that is containing a single specifed language code

do_lang_tempcode(\ID_TEXT $lang_string, \?mixed $token1 = null, \?mixed $token2 = null, \?mixed $token3 = null) : \Tempcode
package core

Parameters

$lang_string

\ID_TEXT

The ID of the language string to use

$token1

\?mixed

The first token [string or Tempcode] (replaces {1}) (null: none)

$token2

\?mixed

The second token [string or Tempcode] (replaces {2}) (null: none)

$token3

\?mixed

The third token (replaces {3}). May be an array of [of string], to allow any number of additional args (null: none)

Returns

\TempcodeA language Tempcode object

Do a UTF8 conversion on the environmental GET/POST parameters (ISO-8859-1 charset, which PHP supports internally).

do_simple_environment_utf8_conversion() 
package core

This is it - the start of rendering of a website page.

do_site() 

Take in all inputs, sends them to the correct functions to process, gathers up all the outputs, sticks them together and echoes them.

package core

Get a Tempcoded version of a Composr template. It is perhaps the most common Composr function to load up templates using do_template, and then attach them together either as parameters to each other, or via the Tempcode attach method.

do_template(\ID_TEXT $codename, \?array $parameters = null, \?LANGUAGE_NAME $lang = null, boolean $light_error = false, \?ID_TEXT $fallback = null, string $suffix = '.tpl', string $directory = 'templates', \?ID_TEXT $theme = null) : \Tempcode
package core
set .tpl .js .xml .txt .css
set templates javascript xml text css

Parameters

$codename

\ID_TEXT

The codename of the template being loaded

$parameters

\?array

A map of parameters for the template (key to value) (null: no parameters)

$lang

\?LANGUAGE_NAME

The language to load the template in (templates can embed language references) (null: users own language)

$light_error

boolean

Whether to not produce a stack dump if the template is missing

$fallback

\?ID_TEXT

Alternate template to use if the primary one does not exist (null: none)

$suffix

string

File type suffix of template file (e.g. .tpl)

$directory

string

Subdirectory type to look in

$theme

\?ID_TEXT

Theme to use (null: current theme)

Returns

\TempcodeThe Tempcode for this template

Find whether the specified language exists.

does_lang_exist(\LANGUAGE_NAME $lang) : boolean
package core

Parameters

$lang

\LANGUAGE_NAME

The language

Returns

booleanWhether the language exists

Evaluate a conventional Tempcode variable, handling escaping

ecv(string $lang, array $escaped, integer $type, \ID_TEXT $name, array $param) : mixed
package core
set 0 2

Parameters

$lang

string

The language to evaluate this symbol in (some symbols refer to language elements).

$escaped

array

Array of escaping operations.

$type

integer

The type of symbol this is (TC_SYMBOL, TC_LANGUAGE_REFERENCE)

$name

\ID_TEXT

The name of the symbol

$param

array

Parameters to the symbol. For all but directive it is an array of strings. For directives it is an array of Tempcode objects. Actually there may be template-style parameters in here, as an influence of singular_bind and these may be Tempcode, but we ignore them.

Returns

mixedThe result. Either Tempcode, or a string.

This function is the integeric partner of either_param_string, as it returns the value as an integer.

either_param_integer(\ID_TEXT $name, \?mixed $default = false) : \?integer

You should always use integer specified versions when inputting integers, for the added security that type validation allows. If the value is of the wrong type, it indicates a hack attempt and will be logged.

package core

Parameters

$name

\ID_TEXT

The name of the parameter to get

$default

\?mixed

The default value to give the parameter if the parameter value is not defined or the empty string (null: allow missing parameter) (false: give error on missing parameter)

Returns

\?integerThe parameter value (null: not set, and NULL given as default)

Get a parameter value (either POST *or* GET, i.e. like $_REQUEST[$name]), or the default if neither can be found.

either_param_string(\ID_TEXT $name, \?mixed $default = false) : \?string

Implements additional security over the direct PHP access mechanism which should not be used.

package core

Parameters

$name

\ID_TEXT

The name of the parameter to get

$default

\?mixed

The default value to give the parameter if the parameter value is not defined (null: allow missing parameter) (false: give error on missing parameter)

Returns

\?stringThe parameter value (null: missing)

Encrypt some data using asymmetric encryption and the site's public key. This will return the original data if encryption is disabled. It will add a magic marker to the start of the returned string to show it's been encrypted.

encrypt_data(string $data) : string

A fatal error will occur if the public key cannot be found, or if encryption fails for whatever reason. Note that this will blindly re-encrypt data which has already been encrypted. You should check data with is_data_encrypted() first.

package core

Parameters

$data

string

Data to be encrypted

Returns

stringEncrypted data, with magic marker

Only allow members here that are either the give member, admins, or have a privilege. All other members come up to an error message wall.

enforce_personal_access(\MEMBER $member_id, \?ID_TEXT $permission = null, \?ID_TEXT $permission2 = null, \?MEMBER $member_viewing = null
package core

Parameters

$member_id

\MEMBER

The member who typically (i.e. when it's not an administrative override) we want the current member to be.

$permission

\?ID_TEXT

The override permission the current member must have (null: no general override).

$permission2

\?ID_TEXT

An alternative permission to the 'assume_any_member' permission (null: no override).

$member_viewing

\?MEMBER

The member who is doing the viewing (null: current member).

Make sure that the given URL contains a session if cookies are disabled.

enforce_sessioned_url(\URLPATH $url) : \URLPATH

NB: This is used for login redirection. It had to add the session ID into the redirect url.

package core

Parameters

$url

\URLPATH

The URL to enforce results in session persistence for the user

Returns

\URLPATHThe fixed URL (potentially nothing was done, depending on cookies)

Make sure temporary passwords restrict you to the edit account page. May not return, if it needs to do a redirect.

enforce_temporary_passwords(\MEMBER $member) 
package core

Parameters

$member

\MEMBER

The current member

Take some image/thumbnail info, and if needed make and caches a thumbnail, and return a thumb url whatever the situation.

ensure_thumbnail(\URLPATH $full_url, \URLPATH $thumb_url, \ID_TEXT $thumb_dir, \ID_TEXT $table, \AUTO_LINK $id, \ID_TEXT $thumb_field_name = 'thumb_url', \?integer $thumb_width = null, boolean $only_make_smaller = false) : \URLPATH
package core

Parameters

$full_url

\URLPATH

The full URL to the image which will-be/is thumbnailed

$thumb_url

\URLPATH

The URL to the thumbnail (blank: no thumbnail yet)

$thumb_dir

\ID_TEXT

The directory, relative to the Composr install's uploads directory, where the thumbnails are stored. MINUS "_thumbs"

$table

\ID_TEXT

The name of the table that is storing what we are doing the thumbnail for

$id

\AUTO_LINK

The ID of the table record that is storing what we are doing the thumbnail for

$thumb_field_name

\ID_TEXT

The name of the table field where thumbnails are saved

$thumb_width

\?integer

The thumbnail width to use (null: default)

$only_make_smaller

boolean

Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images)

Returns

\URLPATHThe URL to the thumbnail

Convert some data from UTF to a character set PHP supports, using HTML entities where there's no direct match.

entity_utf8_decode(string $data, string $internal_charset) : \~string
package core

Parameters

$data

string

Data to convert.

$internal_charset

string

Charset to convert to.

Returns

\~stringConverted data (false: could not convert).

Erase the block cache.

erase_block_cache() 
package core

Erase the language cache.

erase_cached_language() 
package core

Erase all template caches (caches in all themes).

erase_cached_templates(boolean $preserve_some = false
package core

Parameters

$preserve_some

boolean

Whether to preserve CSS and JS files that might be linked to between requests

Erase the Comcode cache. Warning: This can take a long time on large sites, so is best to avoid.

erase_comcode_cache() 
package core

Erase the Comcode page cache

erase_comcode_page_cache() 
package core

Remove all data from the persistent cache and static cache.

erase_persistent_cache() 
package core

Erase the theme images cache

erase_theme_images_cache() 
package core

Erase the thumbnail cache.

erase_thumb_cache() 
package core

Get the specified string, but with all characters escaped.

escape_html(mixed $string) : string
package core

Parameters

$string

mixed

The input string

Returns

stringThe escaped string

Prepare an argument for use literally in a command. Works around common PHP restrictions.

escapeshellarg_wrap(string $arg) : string
package core

Parameters

$arg

string

The argument.

Returns

stringEscaped.

Get special SQL from POSTed parameters for a catalogue search field that is to be exact-matched.

exact_match_sql(array $field, integer $i, \ID_TEXT $type = 'short', \?string $param = null) : \?array
package core
set short long

Parameters

$field

array

The field details

$i

integer

We're processing for the ith row

$type

\ID_TEXT

Table type

$param

\?string

Search term (null: lookup from environment)

Returns

\?arrayTuple of SQL details (array: extra trans fields to search, array: extra plain fields to search, string: an extra table segment for a join, string: the name of the field to use as a title, if this is the title, extra WHERE clause stuff) (null: nothing special)

Execute a background task.

execute_task_background(array $task_row) 
package core

Parameters

$task_row

array

The task row

Export Composr database tables to an equivalent XML format, automatically.

export_to_xml(\?array $tables = null) : string
package core

Parameters

$tables

\?array

List of tables to export (null: all tables except those skippable)

Returns

stringExported data in XML format

Get the string content ID for some data.

extract_content_str_id_from_data(array $data, array $cma_info) : \ID_TEXT
package core

Parameters

$data

array

The data row

$cma_info

array

The info array for the content type

Returns

\ID_TEXTThe ID

Turn a full HTML document into an HTML fragment.

extract_html_body(string $html) : string
package core

Parameters

$html

string

The document

Returns

stringThe fragment

Extract code to execute the requested functions with the requested parameters from the module at the given path.

extract_module_functions(\PATH $path, array $functions, \?array $params = null, boolean $prefer_direct_code_call = false, \?string $class_name = null) : array

We used to actually load up the module, but it ate all our RAM when we did!

package core

Parameters

$path

\PATH

The path to the module (or any PHP file with a class)

$functions

array

Array of functions to be executing

$params

\?array

A list of parameters to pass to our functions (null: none)

$prefer_direct_code_call

boolean

Whether to do this "properly" (via proper OOP), which will consume more memory

$class_name

\?string

Class name to use (null: autodetect, which is a little slower)

Returns

arrayA list of pieces of code to do the equivalent of executing the requested functions with the requested parameters

Extract code to execute the requested functions with the requested parameters from the module requested.

extract_module_functions_page(\ID_TEXT $zone, \ID_TEXT $page, array $functions, \?array $params = null) : array

If it's not a module, returns an empty array.

package core

Parameters

$zone

\ID_TEXT

The zone it is in

$page

\ID_TEXT

The page name

$functions

array

Array of functions to be executing

$params

\?array

A list of parameters to pass to our functions (null: none)

Returns

arrayA list of pieces of code to do the equivalent of executing the requested functions with the requested parameters

Extract the info function from a module at a given path.

extract_module_info(\PATH $path) : \?array
package core

Parameters

$path

\PATH

The path to the module

Returns

\?arrayA module information map (null: module contains no info method)

This function is called when no other language works, and it will return the original default language - 'EN'. You may change this to another language, but this is not advised, as Composr is being shipped with the EN language complete and unabridged as standard - hence you cannot go wrong if you leave it as EN.

fallback_lang() : \LANGUAGE_NAME

In theory, this is the only hook to English that there is.

package core

Returns

\LANGUAGE_NAMEThe fallback language

Create a unique identifer.

fast_uniqid() : string
package core

Returns

stringUnique Identifier

Do a fatal exit, echo the header (if possible) and an error message, followed by a debugging back-trace.

fatal_exit(mixed $text) : mixed

It also adds an entry to the error log, for reference.

package core

Parameters

$text

mixed

The error message (string or Tempcode)

Returns

mixedNever returns (i.e. exits)

Return the output from the conversion between filesize and TAR block size.

file_size_to_tar_block_size(integer $size) : integer
package core

Parameters

$size

integer

The file size of a file that would be inside the TAR archive

Returns

integerThe block size TAR would use to store this file

Filter out any CSS selector blocks from the given CSS if they definitely do not affect the given (X)HTML.

filter_css(\ID_TEXT $c, \?ID_TEXT $theme, string $context) : string

Whilst this is a clever algorithm, it isn't so clever as to actually try and match each selector against a DOM tree. If any segment of a compound selector matches, match is assumed.

package core

Parameters

$c

\ID_TEXT

CSS file

$theme

\?ID_TEXT

Theme (null: default)

$context

string

(X) HTML context under which CSS is filtered

Returns

stringFiltered CSS

Filter to alter form field values based on fields.xml. Usually a no-op.

filter_form_field_default(string $name, \?string $val) : string
package core

Parameters

$name

string

The name of the parameter

$val

\?string

The current value of the parameter (null: none)

Returns

stringThe filtered value of the parameter

Find which of a list of usergroups are permissive ones.

filter_group_permissivity(array $groups) : array
package core

Parameters

$groups

array

List of groups to filter

Returns

arrayList of permissive groups, filtered from those given

Get the parameter put into it, with no changes. If it detects that the parameter is naughty (i.e malicious, and probably from a hacker), it will log the hack-attack and output an error message.

filter_naughty(string $in, boolean $preg = false) : string

This function is designed to be called on parameters that will be embedded in a path, and defines malicious as trying to reach a parent directory using '..'. All file paths in Composr should be absolute

package core

Parameters

$in

string

String to test

$preg

boolean

Whether to just filter out the naughtyness

Returns

stringSame as input string

This function is similar to filter_naughty, except it requires the parameter to be strictly alphanumeric. It is intended for use on text that will be put into an eval.

filter_naughty_harsh(string $in, boolean $preg = false) : string
package core

Parameters

$in

string

String to test

$preg

boolean

Whether to just filter out the naughtyness

Returns

stringSame as input string

Convert some Filtercode filters into some SQL fragments.

filtercode_to_sql(object $db, array $filters, \ID_TEXT $content_type = '', string $context = '', string $table_join_code = 'r') : array
package core

Parameters

$db

object

Database object to use

$filters

array

Parsed Filtercode structure

$content_type

\ID_TEXT

The content type (blank: no function needed, direct in-table mapping always works)

$context

string

First parameter to send to the conversion function, may mean whatever that function wants it to. If we have no conversion function, this is the name of a table to read field metadata from

$table_join_code

string

What MySQL will join the table with

Returns

arrayTuple: array of extra select, array of extra join, string of extra where

Get an array of all the blocks that are currently installed (miniblocks not included).

find_all_blocks() : array
package core

Returns

arrayMap of all blocks (name->[sources/sources_custom])

Get an array of all the hook implementations for a hook class.

find_all_hooks(\ID_TEXT $type, \ID_TEXT $entry) : array
package core
set blocks modules systems

Parameters

$type

\ID_TEXT

The type of hook

$entry

\ID_TEXT

The hook class to find hook implementations for (e.g. the name of a module)

Returns

arrayA map of hook implementation name to [sources|sources_custom]

Get an array of all the installed languages that can be found in root/lang/ and root/lang_custom/

find_all_langs(boolean $even_empty_langs = false) : array
package core

Parameters

$even_empty_langs

boolean

Whether to even find empty languages

Returns

arrayThe installed languages (map, lang=>type)

Get an array of all the modules.

find_all_modules(\ID_TEXT $zone) : array
package core

Parameters

$zone

\ID_TEXT

The zone name

Returns

arrayA map of page name to type (modules_custom, etc)

Get an array of all the pages of the specified type (module, etc) and extension (for small sites everything will be returned, for larger ones it depends on the show method).

find_all_pages(\ID_TEXT $zone, \ID_TEXT $type, string $ext = 'php', boolean $keep_ext_on = false, \?TIME $cutoff_time = null, integer $show_method = 0) : array
package core
set modules comcode html
set 0 1 2

Parameters

$zone

\ID_TEXT

The zone name

$type

\ID_TEXT

The page type

$ext

string

The file extension to limit us to (without a dot)

$keep_ext_on

boolean

Whether to leave file extensions on the page name

$cutoff_time

\?TIME

Only show pages newer than (null: no restriction)

$show_method

integer

Selection algorithm constant

Returns

arrayA map of page name to type (modules_custom, etc)

Get an array of all the pages everywhere in the zone, limited by the selection algorithm (for small sites everything will be returned, for larger ones it depends on the show method).

find_all_pages_wrap(\ID_TEXT $zone, boolean $keep_ext_on = false, boolean $consider_redirects = false, integer $show_method = 0, \?ID_TEXT $page_type = null) : array
package core
set 0 1 2
set modules comcode html

Parameters

$zone

\ID_TEXT

The zone name

$keep_ext_on

boolean

Whether to leave file extensions on the page name

$consider_redirects

boolean

Whether to take transparent redirects into account

$show_method

integer

Selection algorithm constant

$page_type

\?ID_TEXT

Page type to show (null: all)

Returns

arrayA map of page name to type (modules_custom, etc)

Find a list of all the tables that can be imported/exported as XML.

find_all_xml_tables() : array
package core

Returns

arrayList of tables

Find the installed zones, up to the first $max installed

find_all_zones(boolean $search = false, boolean $get_titles = false, boolean $force_all = false, integer $start = 0, integer $max = 50) : array
package core

Parameters

$search

boolean

Whether to search the file system and return zones that might not be fully in the system (otherwise will just use the database)

$get_titles

boolean

Whether to get titles for the zones as well. Only if !$search

$force_all

boolean

Whether to insist on getting all zones without $start/$max parameters (there could be thousands in theory...)

$start

integer

Start position to get results from (ignored if $force_all is on)

$max

integer

Maximum zones to get

Returns

arrayA list of zone names / a list of quartets (name, title, default page, zone row)

Find the cache-on parameters for 'codename's caching style (prevents us needing to load up extra code to find it).

find_cache_on(\ID_TEXT $codename) : \?array
package core

Parameters

$codename

\ID_TEXT

The codename of what will be checked for caching

Returns

\?arrayThe cached result (null: no cached result)

Find the textual moniker for a typical Composr URL path. This will be called from inside build_url, based on details learned from a moniker hook (only if a hook exists to hint how to make the requested link SEO friendly).

find_id_moniker(array $url_parts, \ID_TEXT $zone) : \?string
package core

Parameters

$url_parts

array

The URL component map (must contain 'page', 'type', and 'id' if this function is to do anything).

$zone

\ID_TEXT

The URL zone name (only used for Comcode Page URL monikers).

Returns

\?stringThe moniker ID (null: could not find)

Take a moniker and it's page-link details, and make a full path from it.

find_id_via_url_moniker(\ID_TEXT $content_type, \SHORT_TEXT $url_moniker) : \?ID_TEXT
package core

Parameters

$content_type

\ID_TEXT

The content type.

$url_moniker

\SHORT_TEXT

The URL moniker.

Returns

\?ID_TEXTThe ID (null: not found).

Search the database to find human-readable names for language IDs.

find_lang_content_names(array $ids) : array
package core

Parameters

$ids

array

The language IDs (array of AUTO_LINK)

Returns

arrayHuman readable names (List of string against same IDs in input array or null for orphan strings)

Find bounces in an IMAP folder, with DB caching.

find_mail_bounces(string $server, integer $port, string $folder, string $username, string $password, \?TIME $since = null) : array
package core

Parameters

$server

string

The IMAP server hostname.

$port

integer

The IMAP port.

$folder

string

The IMAP inbox identifier.

$username

string

The IMAP username.

$password

string

The IMAP password.

$since

\?TIME

Only find bounces since this date (null: 8 weeks ago). This is approximate, we will actually look from a bit further back to compensate for possible timezone differences.

Returns

arrayBounces (a map between email address and details of the bounce).

Find IMAP folders.

find_mail_folders(string $server, integer $port, string $username, string $password) : array
package core

Parameters

$server

string

The IMAP server hostname.

$port

integer

The IMAP port.

$username

string

The IMAP username.

$password

string

The IMAP password.

Returns

arrayMap of folders (codenames to display labels).

Find path to the PHP executable.

find_php_path(boolean $cgi = false) : \PATH
package core

Parameters

$cgi

boolean

Whether we need a CGI interpreter

Returns

\PATHPath to PHP

Find the URL to a certain entry point script, located in the root directory, top level of a zone directory, data directory, or data_custom directory.

find_script(string $name, boolean $append_keep = false, integer $base_url_code = 0) : \URLPATH

Why this function? Because Composr allows these to be moved around between zone directories, to suit site .htaccess requirements).

package core
set 0 1 2

Parameters

$name

string

The codename of the needed script

$append_keep

boolean

Whether to append keep variables

$base_url_code

integer

Code representing what base URL type to use (0=guess, 1=http, 2=https)

Returns

\URLPATHThe URL to the script

Find the Sitemap object that serves a particular page-link.

find_sitemap_object(\ID_TEXT $page_link) : \?array
package core

Parameters

$page_link

\ID_TEXT

The page-link we are finding a Sitemap object for (blank: root).

Returns

\?arrayA pair: the Sitemap object, and whether you need to make a virtual call (null: cannot find one).

Search for a template.

find_template_place(\ID_TEXT $codename, \?LANGUAGE_NAME $lang, \ID_TEXT $theme, string $suffix, string $directory, boolean $non_custom_only = false) : \?array
package core
set templates css

Parameters

$codename

\ID_TEXT

The codename of the template being loaded

$lang

\?LANGUAGE_NAME

The language to load the template in (templates can embed language references) (null: users own language)

$theme

\ID_TEXT

The theme to use

$suffix

string

File type suffix of template file (e.g. .tpl)

$directory

string

Subdirectory type to look in

$non_custom_only

boolean

Whether to only search in the default templates

Returns

\?arrayList of parameters needed for the _do_template function to be able to load the template (null: could not find the template)

Convert a template tree structure into a HTML representation.

find_template_tree_nice(\ID_TEXT $codename, array $children, boolean $fresh, boolean $cache_started = false) : string
package core

Parameters

$codename

\ID_TEXT

The codename of the current template item in the recursion

$children

array

The template tree structure for children

$fresh

boolean

Whether the template tree came from a cache (if so, we can take some liberties with it's presentation)

$cache_started

boolean

As $fresh, except something underneath at any unknown point did come from the cache, so this must have by extension

Returns

stringHTML representation

Find the URL to the theme image of the specified ID. It searches various priorities, including language and theme overrides.

find_theme_image(\ID_TEXT $id, boolean $silent_fail = false, boolean $leave_local = false, \?ID_TEXT $theme = null, \?LANGUAGE_NAME $lang = null, \?object $db = null, boolean $pure_only = false) : \URLPATH
package core

Parameters

$id

\ID_TEXT

The theme image ID

$silent_fail

boolean

Whether to silently fail (i.e. not give out an error message when a theme image cannot be found)

$leave_local

boolean

Whether to leave URLs as relative local URLs

$theme

\?ID_TEXT

The theme to search in (null: users current theme)

$lang

\?LANGUAGE_NAME

The language to search for (null: users current language)

$db

\?object

The database to use (null: site database)

$pure_only

boolean

Whether to only search the default 'images' filesystem

Returns

\URLPATHThe URL found (blank: not found)

Fixes bad unicode (utf-8) in the input. Useful when input may be dirty, e.g. from a txt file, or from a potential hacker.

fix_bad_unicode(string $input, boolean $definitely_unicode = false) : string

The fix is imperfect, it will actually treat the input as ISO-8859-1 if not valid utf-8, then reconvert. Some limited scrambling is considered better than a stack trace. This function does nothing if we are not using utf-8.

package core

Parameters

$input

string

Input string

$definitely_unicode

boolean

If we know the input is meant to be unicode

Returns

stringGuaranteed valid utf-8, if we're using it, otherwise the same as the input string

Make a value suitable for use in an XML ID.

fix_id(string $param) : string
package core

Parameters

$param

string

The value to escape

Returns

stringThe escaped value

Ensure that the specified file/folder is writeable for the FTP user (so that it can be deleted by the system), and should be called whenever a file is uploaded/created, or a folder is made. We call this function assuming we are giving world permissions.

fix_permissions(\PATH $path, integer $perms = 438
package core

Parameters

$path

\PATH

The full pathname to the file/directory

$perms

integer

The permissions to make (not the permissions are reduced if the function finds that the file is owned by the web user [doesn't need world permissions then])

Sometimes users don't enter full URLs but do intend for them to be absolute. This code tries to see what relative URLs are actually absolute ones, via an algorithm. It then fixes the URL.

fixup_protocolless_urls(\URLPATH $in) : \URLPATH
package core

Parameters

$in

\URLPATH

The URL to fix

Returns

\URLPATHThe fixed URL (or original one if no fix was needed)

Turn an array into a humanely readable string.

flatten_slashed_array(array $array, boolean $already_stripped = false) : string
package core

Parameters

$array

array

Array to convert

$already_stripped

boolean

Whether PHP magic-quotes have already been cleaned out for the array

Returns

stringA humanely readable version of the array.

Format the given float number as a nicely formatted string.

float_format(float $val, integer $decs_wanted = 2, boolean $only_needed_decs = false) : string
package core

Parameters

$val

float

The value to format

$decs_wanted

integer

The number of fractional digits

$only_needed_decs

boolean

Whether to trim trailing zeros

Returns

stringNicely formatted string

Convert a float to a "technical string representation of a float".

float_to_raw_string(float $num, integer $decs_wanted = 2, boolean $only_needed_decs = false) : string
package core

Parameters

$num

float

The number

$decs_wanted

integer

The number of decimals to keep

$only_needed_decs

boolean

Whether to trim trailing zeros

Returns

stringThe string converted

Make sure that the AFM connection details have been posted. If not, get them and loop back.

force_have_afm_details() 
package core

Force an HTTP authentication login box / relay it as if it were a posted login. This function is rarely used.

force_httpauth() 
package core

Get a form for inputting unknown variables within a filter.

form_for_filtercode(string $filter, \?array $labels = null, \?ID_TEXT $content_type = null, \?array $types = null) : array
package core

Parameters

$filter

string

String-based search filter (blank: make one up to cover everything, but only works if $table is known)

$labels

\?array

Labels for field names (null: none, use auto-generated)

$content_type

\?ID_TEXT

Content-type to auto-probe from (null: none, use string inputs)

$types

\?array

Field types (null: none, use string inputs / defaults for table)

Returns

arrayThe form fields, The modded filter, Merger links

Get the Tempcode for a hidden form element.

form_input_hidden(\ID_TEXT $name, string $value) : \Tempcode
package core

Parameters

$name

\ID_TEXT

The name which this input field is for

$value

string

The value for this input field

Returns

\TempcodeThe input field

Get the Tempcode for a list entry. (You would gather together the outputs of several of these functions, then put them in as the $content in a form_input_list function call).

form_input_list_entry(string $value, boolean $selected = false, mixed $text = '', boolean $red = false, boolean $disabled = false) : \Tempcode
package core

Parameters

$value

string

The value for this entry

$selected

boolean

Whether this entry is selected by default or not (Note: if nothing else is selected and this is the first, it will be selected by default anyway)

$text

mixed

The text associated with this choice (blank: just use name for text)

$red

boolean

Whether this entry will be put as red (marking it as important somehow)

$disabled

boolean

Whether this list entry is disabled (like a header in a list)

Returns

\TempcodeThe input field

Get the Tempcode for a group of list entry. May be attached directly to form_input_list_entry (i.e. this is a group node in a shared tree), and also fed into form_input_list.

form_input_list_group(mixed $title, \Tempcode $entries) : \Tempcode
package core

Parameters

$title

mixed

The title for the group

$entries

\Tempcode

List entries for group

Returns

\TempcodeThe group

Send the posted form over email to the staff address.

form_to_email(\?string $subject = null, string $intro = '', \?array $fields = null, \?string $to_email = null, string $outro = '', boolean $is_via_post = true
package core

Parameters

$subject

\?string

The subject of the email (null: from posted subject parameter).

$intro

string

The intro text to the mail (blank: none).

$fields

\?array

A map of fields to field titles to transmit. (null: all posted fields, except subject and email)

$to_email

\?string

Email address to send to (null: look from post environment / staff address).

$outro

string

The outro text to the mail (blank: none).

$is_via_post

boolean

Whether $fields refers to some POSTed fields, as opposed to a direct field->value map.

Entry script to process a form that needs to be emailed.

form_to_email_entry_script() 
package core

Convert text to an entity format via unicode, compatible with the GD TTF functions. Originally taken from php manual but heavily modified. Passed text is assumed to be in the get_charset() character set.

foxy_utf8_to_nce(string $data = '') : string
package core

Parameters

$data

string

Input text.

Returns

stringOutput 7-bit unicode-entity-encoded ASCII text.

Find whether a fractional edit is underway.

fractional_edit() : boolean
package core

Returns

booleanWhether a fractional edit is underway

Produce a key we can use for SQL join names, from some string that may be too complex for this. It should be reproducible and unique for the given input.

generate_filtercode_join_key_from_string(string $str) : string
package core

Parameters

$str

string

Input string

Returns

stringSuitable key name

Generate a GUID.

generate_guid() : \ID_TEXT
package core

Returns

\ID_TEXTA GUID

Highlight keywords in an extracted portion of a piece of text.

generate_text_summary(string $_temp_summary, array $words_searched) : string
package core

Parameters

$_temp_summary

string

What was searched

$words_searched

array

List of words searched

Returns

stringHighlighted portion

Find the country an IP address long is located in

geolocate_ip(\?IP $ip = null) : \?string
package core

Parameters

$ip

\?IP

The IP to geolocate (null: current user's IP)

Returns

\?stringThe country initials (null: unknown)

Force an AFM login.

get_afm_form() 
package core

Get the fields that need to be filled in to know how to do an AFM connection.

get_afm_form_fields() : \Tempcode
package core

Returns

\TempcodeThe form fields.

Get a comma-separated list of allowed file types for audio upload.

get_allowed_audio_file_types() : string
package core

Returns

stringAllowed file types

Get a comma-separated list of allowed file types for audio upload.

get_allowed_image_file_types() : string
package core

Returns

stringAllowed file types

Find partner sites allowed to do cross-domain requests to us.

get_allowed_partner_sites() : array
package core

Returns

arrayPartner domain names

Get a comma-separated list of allowed file types for video upload.

get_allowed_video_file_types() : string
package core

Returns

stringAllowed file types

Get the base url (the minimum fully qualified URL to our installation).

get_base_url(\?boolean $https = null, \?ID_TEXT $zone_for = null) : \URLPATH
package core

Parameters

$https

\?boolean

Whether to get the HTTPS base URL (null: do so only if the current page uses the HTTPS base URL)

$zone_for

\?ID_TEXT

The zone the link is for (null: root zone)

Returns

\URLPATHThe base-url

Get a unique ID representing a block call.

get_block_id(array $map) : \ID_TEXT
package core

Parameters

$map

array

The block parameter map

Returns

\ID_TEXTThe block ID

Get standardised info about a block.

get_block_info_row(\ID_TEXT $codename, array $map) : \?array
package core

Parameters

$codename

\ID_TEXT

The block name

$map

array

The block parameter map

Returns

\?arrayThe block info (null: cannot cache for some reason)

Gets parameters for a block

get_block_parameters(\ID_TEXT $block) : array
package core

Parameters

$block

\ID_TEXT

The name of the block to get parameters for

Returns

arrayA list of parameters the block takes

Get the name of a webcrawler bot, or NULL if no bot detected

get_bot_type() : \?string
package core

Returns

\?stringWebcrawling bot name (null: not a bot)

Find the base URL for documentation.

get_brand_base_url() : \URLPATH
package core

Returns

\URLPATHThe base URL for documentation

Get a URL to a compo.sr page.

get_brand_page_url(array $params, \ID_TEXT $zone) : \URLPATH
package core

Parameters

$params

array

URL map

$zone

\ID_TEXT

Zone

Returns

\URLPATHURL to page

Get a string of the users web browser

get_browser_string() : string
package core

Returns

stringThe web browser string

Find the cached result of what is named by codename and the further constraints.

get_cache_entry(\ID_TEXT $codename, \LONG_TEXT $cache_identifier, integer $special_cache_flags, integer $ttl = 10000, boolean $tempcode = false, boolean $caching_via_cron = false, \?array $map = null) : \?mixed
package core

Parameters

$codename

\ID_TEXT

The codename to check for caching

$cache_identifier

\LONG_TEXT

The further restraints (a serialized map)

$special_cache_flags

integer

Special cache flags

$ttl

integer

The TTL for the cache entry. Defaults to a very big ttl

$tempcode

boolean

Whether we are caching Tempcode (needs special care)

$caching_via_cron

boolean

Whether to defer caching to CRON. Note that this option only works if the block's defined cache signature depends only on $map (timezone and bot-type are automatically considered)

$map

\?array

Parameters to call up block with if we have to defer caching (null: none)

Returns

\?mixedThe cached result (null: no cached result)

Gather the permissions for the specified category as a form field input matrix.

get_category_permissions_for_environment(\ID_TEXT $module, \ID_TEXT $category, \?ID_TEXT $page = null, \?Tempcode $help = null, boolean $new_category = false, \?Tempcode $pinterface_view = null) : \Tempcode
package core

Parameters

$module

\ID_TEXT

The ID code for the module being checked for category access

$category

\ID_TEXT

The ID code for the category being checked for access (often, a number cast to a string)

$page

\?ID_TEXT

The page this is for (null: current page)

$help

\?Tempcode

Extra help to show in interface (null: none)

$new_category

boolean

Whether this is a new category (don't load permissions, default to on)

$pinterface_view

\?Tempcode

Label for view permissions (null: default)

Returns

\TempcodeThe form field matrix

Get hidden fields for setting category access permissions as on.

get_category_permissions_hidden_on() : \Tempcode
package core

Returns

\TempcodeHidden fields

Get the character set to use. We try and be clever to allow AJAX scripts to avoid loading up language

get_charset() : string
package core

Returns

stringThe character set

Get the list of files that need CHmodding for write access.

get_chmod_array(\ID_TEXT $lang) : array
package core

Parameters

$lang

\ID_TEXT

Language to use

Returns

arrayThe list of files

Get the value of a special 'cms_' custom profile field. For Conversr it can also do it for a pure field title, e.g. "Example Field".

get_cms_cpf(\ID_TEXT $cpf, \?MEMBER $member = null) : string
package core

Parameters

$cpf

\ID_TEXT

The CPF name stem

$member

\?MEMBER

Member to lookup for (null: current member)

Returns

stringThe value (blank: has a blank value, or does not exist)

Find what zones a member may edit Comcode pages in.

get_comcode_page_editability_per_zone(\?MEMBER $member = null) : array
package core

Parameters

$member

\?MEMBER

The member being checked for access (null: current member)

Returns

arrayA list of pairs: The zone name, and a bitmask of COMCODE_EDIT_* constants identifying the level of editing permission present

Find the zone a Comcode page is in.

get_comcode_zone(\ID_TEXT $page_name, boolean $error = true) : \?ID_TEXT
package core

Parameters

$page_name

\ID_TEXT

The Comcode page name to find

$error

boolean

Whether Composr should bomb out if the page was not found

Returns

\?ID_TEXTThe zone the Comcode page is in (null: missing)

Function to get a base URL for an Conversr relative-URL. The situation is complex as it needs to take into account Conversr multi-site-network's, locally defined theme images, and shared-installs (Demonstratr style).

get_complex_base_url(\URLPATH $at) : \URLPATH
package core

Parameters

$at

\URLPATH

Short base URL we need to probe

Returns

\URLPATHThe appropriate base-url

Get the CMA hook object for a content type. Also works for resource types (i.e. if it's a resource, although not actually considered content technically).

get_content_object(\ID_TEXT $content_type) : \?object
package core

Parameters

$content_type

\ID_TEXT

The content type

Returns

\?objectThe object (null: could not get one)

Given the string content ID get a mapping we could use as a WHERE map.

get_content_where_for_str_id(\ID_TEXT $str_id, array $cma_info, \?string $table_alias = null) : array
package core

Parameters

$str_id

\ID_TEXT

The ID

$cma_info

array

The info array for the content type

$table_alias

\?string

The table alias (null: none)

Returns

arrayThe mapping

Get the base url (the minimum fully qualified URL to our personal data installation). For a shared install, or a GAE-install, this is different to the base-url.

get_custom_base_url(\?boolean $https = null) : \URLPATH
package core

Parameters

$https

\?boolean

Whether to get the HTTPS base URL (null: do so only if the current page uses the HTTPS base URL)

Returns

\URLPATHThe base-url

Get the file base for your installation of Composr. For a shared install, or a GAE-install, this is different to the file-base.

get_custom_file_base() : \PATH
package core

Returns

\PATHThe file base, without a trailing slash

Get the name of the forum database.

get_db_forums() : string
package core

Returns

stringThe forum database site

Get the host of the forum database ('localhost', for example).

get_db_forums_host() : string
package core

Returns

stringThe database host

Get the forum database password.

get_db_forums_password() : string
package core

Returns

stringThe forum database password

Get the forum database username.

get_db_forums_user() : string
package core

Returns

stringThe forum database username

Returns a list of keywords for all databases we might some day support.

get_db_keywords() : array
package core

Returns

arrayList of pairs

Get the name of the database.

get_db_site() : string
package core

Returns

stringThe database site

Get the host of the database ('localhost', for example).

get_db_site_host() : string
package core

Returns

stringThe database host

Get the database password.

get_db_site_password() : string
package core

Returns

stringThe database password

Get the database username.

get_db_site_user() : string
package core

Returns

stringThe database username

Get the type of database installed, such as MySQL, or Oracle.

get_db_type() : string
package core

Returns

stringThe database type

Get the default value of a config option.

get_default_option(\ID_TEXT $name) : \?SHORT_TEXT
package core

Parameters

$name

\ID_TEXT

The name of the option

Returns

\?SHORT_TEXTThe value (null: disabled)

Get the name of the default theme, assuming it exists. This is based on the site name.

get_default_theme_name() : string
package core

Returns

stringTheme name

Get the contents of a directory, recursively. It is assumed that the directory exists.

get_directory_contents(\PATH $path, \PATH $rel_path = '', boolean $special_too = false, boolean $recurse = true, boolean $files_wanted = true) : array
package core

Parameters

$path

\PATH

The path to search

$rel_path

\PATH

The path we prepend to everything we find (intended to be used inside the recursion)

$special_too

boolean

Whether to also get special files

$recurse

boolean

Whether to recurse (if not, will return directories as files)

$files_wanted

boolean

Whether to get files (if not, will return directories as files)

Returns

arrayThe contents of the directory

Get the size in bytes of a directory. It is assumed that the directory exists.

get_directory_size(\PATH $path, boolean $recurse = true) : integer
package core

Parameters

$path

\PATH

The path to search

$recurse

boolean

Whether to recurse (if not, will return directories as files)

Returns

integerThe extra space requested

Get the display name of a username.

get_displayname(\ID_TEXT $username) : \SHORT_TEXT

If no display name generator is configured, this will be the same as the username.

package core

Parameters

$username

\ID_TEXT

The username

Returns

\SHORT_TEXTThe display name

Get the domain the website is installed on (preferably, without any www). The domain is used for e-mail defaults amongst other things.

get_domain() : string
package core

Returns

stringThe domain of the website

Get metadata from an image, using EXIF primarily, but also XMP and IPTC to get image descriptions.

get_exif_data(\PATH $path, \?string $filename = null) : array

Also gets GPS data and canonicalises in decimal as Latitude and Longitude.

package core

Parameters

$path

\PATH

This is the path of the photo which may contain metadata

$filename

\?string

This is the original filename of the photo which may contain metadata (null: derive from path)

Returns

arrayMap of metadata, using standard EXIF naming

Attempt to retrieve a caption from photos seeking XMP, then EXIF, then IPTC binary last.

get_exif_image_caption(\PATH $path, string $filename) : string

Check this file is a valid image file before passing to this function as an empty string often annoys.

package core

Parameters

$path

\PATH

This is the path of the photo which may contain metadata

$filename

string

This is the original filename of the photo which may contain metadata

Returns

stringWhichever caption is found

Returns a list of pairs, for which permissions are false by default for ordinary usergroups.

get_false_permissions() : array
package core

Returns

arrayList of pairs

Get the file base for your installation of Composr

get_file_base() : \PATH
package core

Returns

\PATHThe file base, without a trailing slash

Get the file extension of the specified file. It returns without a dot.

get_file_extension(string $name) : string
package core

Parameters

$name

string

The filename

Returns

stringThe filename extension (no dot)

Get a formatted-string filesize for the specified file. It is formatted as such: x MB/KB/Bytes (or unknown). It is assumed that the file exists.

get_file_size(\URLPATH $url) : string
package core

Parameters

$url

\URLPATH

The URL that the file size of is being worked out for. Should be local.

Returns

stringThe formatted-string file size

Get the first admin user.

get_first_admin_user() : \MEMBER
package core

Returns

\MEMBERAdmin user

Get the installed forum base URL.

get_forum_base_url(boolean $forum_base = false) : \URLPATH
package core

Parameters

$forum_base

boolean

Whether to get the base directory of the forum. Unless running Conversr, this makes no difference - if possibly running Conversr, you need to think about this parameter: are you trying to reach the MSN-central-site or just a link to the forums?

Returns

\URLPATHThe installed forum base URL

Get the type of forums installed.

get_forum_type() : string
package core

Returns

stringThe type of forum installed

Find the MD5 hash of the space-stripped copy of function within the given code.

get_function_hash(string $code, string $function) : \SHORT_TEXT
package core

Parameters

$code

string

The code.

$function

string

Name of the function.

Returns

\SHORT_TEXTThe MD5 hash (blank: no such function).

Get information about new versions of Composr (or more accurately, what's wrong with this version).

get_future_version_information() : \Tempcode
package core

Returns

\TempcodeInformation about the installed Composr version

Get the version number of GD on the system. It should only be called if GD is known to be on the system, and in use

get_gd_version() : float
package core

Returns

floatThe version of GD installed

Return a debugging back-trace of the current execution stack. Use this for debugging purposes.

get_html_trace() : \Tempcode
package core

Returns

\TempcodeDebugging backtrace

Sanitise a POST inputted date, and get the Unix timestamp for the inputted date.

get_input_date(\ID_TEXT $stub, boolean $get_also = false, boolean $do_timezone_conversion = true) : \?TIME
package core

Parameters

$stub

\ID_TEXT

The stub of the parameter name (stub_year, stub_month, stub_day, stub_hour, stub_minute)

$get_also

boolean

Whether to allow over get parameters also

$do_timezone_conversion

boolean

Whether to do timezone conversion

Returns

\?TIMEThe timestamp of the date (null: no input date was chosen)

Sanitise a POST inputted date, and get the dat/time components.

get_input_date_components(\ID_TEXT $stub, \?integer $year = null, \?integer $month = null, \?integer $day = null, boolean $get_also = false) : array
package core

Parameters

$stub

\ID_TEXT

The stub of the parameter name (stub_year, stub_month, stub_day, stub_hour, stub_minute)

$year

\?integer

Default year (null: none)

$month

\?integer

Default month (null: none)

$day

\?integer

Default day (null: none)

$get_also

boolean

Whether to allow over get parameters also

Returns

arrayThe date/time components

Attempt to get the clean IP address of the current user

get_ip_address(integer $amount = 4, \?IP $ip = null) : \IP
package core
set 1 2 3 4

Parameters

$amount

integer

The number of groups to include in the IP address (rest will be replaced with *'s). For IP6, this is doubled.

$ip

\?IP

IP address to use, normally left NULL (null: current user's)

Returns

\IPThe users IP address (blank: could not find a valid one)

Get the current language.

get_lang(\?MEMBER $member = null) : \LANGUAGE_NAME

First it tries to get the GET or POST language values, then it tries the user's language, then site default, then it resorts to EN.

package core

Parameters

$member

\?MEMBER

The member ID (null: site default language, although better just to call get_site_default_lang directly)

Returns

\LANGUAGE_NAMEThe current language

Get the closest fit language code to what the browser is requesting.

get_lang_browser() : \?LANGUAGE_NAME
package core

Returns

\?LANGUAGE_NAMEThe closest-fit language to what the browser wants (null: browser doesn't ask)

Get an array of all the INI description entries in the specified language.

get_lang_file_descriptions(\LANGUAGE_NAME $lang, \?ID_TEXT $file = null) : array
package core

Parameters

$lang

\LANGUAGE_NAME

The language

$file

\?ID_TEXT

The language file (null: all non-custom language files)

Returns

arrayThe language descriptions

Get an array of all the INI language entries in the specified language.

get_lang_file_map(\LANGUAGE_NAME $lang, \ID_TEXT $file, boolean $non_custom = false) : array
package core

Parameters

$lang

\LANGUAGE_NAME

The language

$file

\ID_TEXT

The language file

$non_custom

boolean

Force usage of original file

Returns

arrayThe language entries

Get a list of languages files for the given language. ONLY those that are overridden.

get_lang_files(\?LANGUAGE_NAME $lang = null) : array
package core

Parameters

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

Returns

arrayThe language files

Get what language the given member uses. The language is sent through a mapping to ensure it is in the right format, or dumped if it will not map.

get_lang_member(\MEMBER $member) : \?LANGUAGE_NAME
package core

Parameters

$member

\MEMBER

The member ID

Returns

\?LANGUAGE_NAMEThe language used by the member (null: the language will not map)

Get Tempcode for tags, based on loaded up from SEO keywords (seo_meta_load_for).

get_loaded_tags(\?ID_TEXT $limit_to = null, \?array $the_tags = null) : \Tempcode
package core

Parameters

$limit_to

\?ID_TEXT

The search code for this tag content (e.g. downloads) (null: there is none)

$the_tags

\?array

Explicitly pass a list of tags instead (null: use loaded ones)

Returns

\TempcodeLoaded tag output (or blank if there are none)

Get the relative URL to the logo for the current zone.

get_logo_url(\?ID_TEXT $zone_name = null) : \URLPATH
package core

Parameters

$zone_name

\?ID_TEXT

The zone being operated within (null: auto-detect)

Returns

\URLPATHThe relative URL to the logo for the current zone

Find if a mass-import is in progress.

get_mass_import_mode() : boolean
package core

Returns

booleanIf it is

Get the maximum allowed upload filesize, as specified in the configuration

get_max_file_size(\?MEMBER $source_member = null, \?object $connection = null) : integer
package core

Parameters

$source_member

\?MEMBER

Member we consider quota for (null: do not consider quota)

$connection

\?object

Database connection to get quota from (null: site DB)

Returns

integerThe maximum allowed upload filesize, in bytes

Get the maximum allowed image size, as set in the configuration.

get_max_image_size() : integer
package core

Returns

integerThe maximum image size

Get the ID of the currently active member.

get_member(boolean $quick_only = false) : \MEMBER

It see's if the session exists / cookie is valid -- and gets the member ID accordingly

package core

Parameters

$quick_only

boolean

Whether to just do a quick check, don't establish new sessions

Returns

\MEMBERThe member requesting this web page (possibly the guest member - which strictly speaking, is not a member)

Get a map of members viewing the specified Composr location.

get_members_viewing(\?ID_TEXT $page = null, \?ID_TEXT $type = null, \?SHORT_TEXT $id = null, boolean $forum_layer = false) : \?array
package core

Parameters

$page

\?ID_TEXT

The page they need to be viewing (null: environment current) (blank: blank't care)

$type

\?ID_TEXT

The page-type they need to be viewing (null: environment current) (blank: don't care)

$id

\?SHORT_TEXT

The type-id they need to be viewing (null: environment current) (blank: don't care)

$forum_layer

boolean

Whether this has to be done over the forum driver (multi site network)

Returns

\?arrayA map of member-IDs to rows about them (except for guest, which is a count) (null: Too many / disabled)

Get template-ready details of members viewing the specified Composr location.

get_members_viewing_wrap(\?ID_TEXT $page = null, \?ID_TEXT $type = null, \?SHORT_TEXT $id = null, boolean $forum_layer = false) : \?array
package core

Parameters

$page

\?ID_TEXT

The page they need to be viewing (null: don't care)

$type

\?ID_TEXT

The page-type they need to be viewing (null: don't care)

$id

\?SHORT_TEXT

The type-id they need to be viewing (null: don't care)

$forum_layer

boolean

Whether this has to be done over the forum driver (multi site network)

Returns

\?arrayA map of member-IDs to rows about them (null: Too many)

Find the mime type for the given file extension. It does not take into account whether the file type has been white-listed or not, and returns a binary download mime type for any unknown extensions.

get_mime_type(string $extension, boolean $as_admin) : string
package core

Parameters

$extension

string

The file extension (no dot)

$as_admin

boolean

Whether there are admin privileges, to render dangerous media types (client-side risk only)

Returns

stringThe MIME type

Find a user to test access against, if we're planning on making presence of something public.

get_modal_user() : \MEMBER
package core

Returns

\MEMBERThe modal member

Find the zone a page is in.

get_module_zone(\ID_TEXT $module_name, \ID_TEXT $type = 'modules', \?string $dir2 = null, string $ftype = 'php', boolean $error = true) : \?ID_TEXT
package core

Parameters

$module_name

\ID_TEXT

The page name to find

$type

\ID_TEXT

The type of the page we are looking for

$dir2

\?string

The special subcategorisation of page we are looking for (e.g. 'EN' for a Comcode page) (null: none)

$ftype

string

The file extension for the page type

$error

boolean

Whether Composr should bomb out if the page was not found

Returns

\?ID_TEXTThe zone the page is in (null: not found)

Get the largest amount of users ever to be on the site at the same time.

get_num_users_peak() : integer
package core

Returns

integerThe number of peak users

Get the number of users on the site in the last 5 minutes. The function also maintains the statistic via the sessions table.

get_num_users_site() : integer
package core

Returns

integerThe number of users on the site

Find the value of the specified configuration option.

get_option(\ID_TEXT $name, boolean $missing_ok = false) : \?SHORT_TEXT
package core

Parameters

$name

\ID_TEXT

The name of the option

$missing_ok

boolean

Where to accept a missing option (and return NULL)

Returns

\?SHORT_TEXTThe value (null: either null value, or no option found whilst $missing_ok set)

Get the ordinal suffix (e.g. nd, rd, st) for a number.

get_ordinal_suffix(integer $index) : string
package core

Parameters

$index

integer

Number to do this for

Returns

stringThe suffix

Get the user's operating system

get_os_string() : string
package core

Returns

stringThe operating system string

Get the name of the current page

get_page_name() : \ID_TEXT
package core

Returns

\ID_TEXTThe current page name

Gather the permissions for the specified page as form field inputs.

get_page_permissions_for_environment(\ID_TEXT $zone, \ID_TEXT $page, \?Tempcode $help = null) : \Tempcode
package core

Parameters

$zone

\ID_TEXT

The ID code for the zone

$page

\ID_TEXT

The ID code for the page

$help

\?Tempcode

Extra help to show in interface (null: none)

Returns

\TempcodeThe form fields

A page is not validated, so show a warning.

get_page_warning_details(\ID_TEXT $zone, \ID_TEXT $codename, \Tempcode $edit_url) : \Tempcode
package core

Parameters

$zone

\ID_TEXT

The zone the page is being loaded from

$codename

\ID_TEXT

The codename of the page

$edit_url

\Tempcode

The edit URL (blank if no edit access)

Returns

\TempcodeThe warning

Find the zone a page is in.

get_page_zone(\ID_TEXT $page_name, boolean $error = true) : \?ID_TEXT
package core

Parameters

$page_name

\ID_TEXT

The page name to find

$error

boolean

Whether Composr should bomb out if the page was not found

Returns

\?ID_TEXTThe zone the page is in (null: missing)

This function is the integeric partner of get_param_string, as it returns the value as an integer.

get_param_integer(\ID_TEXT $name, \?mixed $default = false, boolean $not_string_ok = false) : \?integer
package core

Parameters

$name

\ID_TEXT

The name of the parameter to get

$default

\?mixed

The default value to give the parameter if the parameter value is not defined or the empty string (null: allow missing parameter) (false: give error on missing parameter)

$not_string_ok

boolean

If a string is given, use the default parameter rather than giving an error (only use this if you are suffering from a parameter conflict situation between different parts of Composr)

Returns

\?integerThe parameter value (null: not set, and NULL given as default)

Get the value of the specified GET parameter (i.e. like $_GET[$name]) if it is passed, or the default otherwise.

get_param_string(\ID_TEXT $name, \?mixed $default = false, boolean $no_security = false) : \?string

Implements additional security over the direct PHP access mechanism which should not be used.

package core

Parameters

$name

\ID_TEXT

The name of the parameter to get

$default

\?mixed

The default value to give the parameter if the parameter value is not defined (null: allow missing parameter) (false: give error on missing parameter)

$no_security

boolean

Whether to skip the security check

Returns

\?stringThe parameter value (null: missing)

Create a form field input matrix for permission setting.

get_permissions_matrix(\ID_TEXT $server_id, array $access, array $overridables, array $privileges, array $default_access, boolean $no_outer = false, \?Tempcode $pinterface_view = null) : \Tempcode
package core

Parameters

$server_id

\ID_TEXT

Permission ID (page_link style) for the resource being set

$access

array

An inverted list showing what view permissions are set for what we're setting permissions for

$overridables

array

List of overridable privilege codes for what we're setting permissions for

$privileges

array

List of privilege settings relating to what we're setting permissions for, from the database

$default_access

array

Multi-dimensional array showing what the inherited defaults for this permission would be

$no_outer

boolean

Whether to not include the stuff to make it fit alongside other form fields in a normal form table

$pinterface_view

\?Tempcode

Label for view permissions (null: default)

Returns

\TempcodeThe form field matrix

Get a randomised password.

get_rand_password() : string
package core

Returns

stringThe randomised password

Find the list of URL remappings

get_remappings(\ID_TEXT $url_scheme) : array
package core

Parameters

$url_scheme

\ID_TEXT

The URL scheme to use

Returns

arrayThe list of URL remappings

Get Comcode pages from a zone, that sit in the root of that zone.

get_root_comcode_pages(\ID_TEXT $zone, boolean $include_zone = false) : array
package core

Parameters

$zone

\ID_TEXT

The zone to get for.

$include_zone

boolean

Use page-links in the mapping rather than just page names.

Returns

arrayRoot Comcode pages, mapping page name to validation status.

Get the Tempcode for a page title. (Ones below the page header, not in the browser title bar.)

get_screen_title(mixed $title, boolean $dereference_lang = true, \?array $params = null, \?Tempcode $user_online_title = null, \?array $awards = null, boolean $save_as_metadata = true) : \Tempcode
package core
sets_output_state

Parameters

$title

mixed

The title to use (usually, a language string code, see below)

$dereference_lang

boolean

Whether the given title is actually a language string code, and hence gets dereferenced

$params

\?array

Parameters sent to the language string (null: none)

$user_online_title

\?Tempcode

Separate title to put into the 'currently viewing' data (null: use $title)

$awards

\?array

Awards to say this has won (null: none)

$save_as_metadata

boolean

Whether to use this as metadata for the screen

Returns

\TempcodeThe title Tempcode

Get some rows, queried from the database according to the search parameters.

get_search_rows(\?ID_TEXT $meta_type, \?ID_TEXT $meta_id_field, string $content, boolean $boolean_search, \ID_TEXT $boolean_operator, boolean $only_search_meta, \ID_TEXT $direction, integer $max, integer $start, boolean $only_titles, \ID_TEXT $table, array $fields, string $where_clause, string $content_where, \ID_TEXT $order, string $select = '*', \?array $raw_fields = null, \?string $permissions_module = null, \?string $permissions_field = null, boolean $permissions_field_is_string = false) : array
package core
set OR AND

Parameters

$meta_type

\?ID_TEXT

The META type used by our content (null: Cannot support META search)

$meta_id_field

\?ID_TEXT

The name of the field that retrieved META IDs will relate to (null: Cannot support META search)

$content

string

Search string

$boolean_search

boolean

Whether to do a boolean search.

$boolean_operator

\ID_TEXT

Boolean operator

$only_search_meta

boolean

Whether to only do a META (tags) search

$direction

\ID_TEXT

Order direction

$max

integer

Start position in total results

$start

integer

Maximum results to return in total

$only_titles

boolean

Whether to only search titles (as opposed to both titles and content)

$table

\ID_TEXT

The table name

$fields

array

The translateable fields to search over (or an ! which is skipped). The first of these must be the title field or an '!'; if it is '!' then the title field will be the first raw-field

$where_clause

string

The WHERE clause

$content_where

string

The WHERE clause that applies specifically for content (this will be duplicated to check against multiple fields). ? refers to the yet-unknown field name

$order

\ID_TEXT

What to order by

$select

string

What to select

$raw_fields

\?array

The non-translateable fields to search over (null: there are none)

$permissions_module

\?string

The permission module to check category access for (null: none)

$permissions_field

\?string

The field that specifies the permissions ID to check category access for (null: none)

$permissions_field_is_string

boolean

Whether the permissions field is a string

Returns

arrayThe rows found

Get a secure random number, the best this PHP version can do.

get_secure_random_number() : integer
package core

Returns

integerThe randomised number

Get a well formed URL equivalent to the current URL.

get_self_url(boolean $evaluate = false, boolean $root_if_posted = false, \?array $extra_params = null, boolean $posted_too = false, boolean $avoid_remap = false) : mixed
package core

Parameters

$evaluate

boolean

Whether to evaluate the URL (so as we don't return Tempcode)

$root_if_posted

boolean

Whether to direct to the default page if there was a POST request leading to where we are now (i.e. to avoid missing post fields when we go to this URL)

$extra_params

\?array

A map of extra parameters for the URL (null: none)

$posted_too

boolean

Whether to also keep POSTed data, in the GET request (useful if either_param_string is used to get the data instead of post_param_string - of course the POST data must be of the not--persistent-state-changing variety)

$avoid_remap

boolean

Whether to avoid mod_rewrite (sometimes essential so we can assume the standard URL parameter addition scheme in templates)

Returns

mixedThe URL (Tempcode or string)

Get a well formed URL equivalent to the current URL. Reads direct from the environment and does no clever mapping at all. This function should rarely be used.

get_self_url_easy() : \URLPATH
package core

Returns

\URLPATHThe URL

Get the timezone the server is configured with.

get_server_timezone() : string
package core

Returns

stringServer timezone in "boring" format.

Get the current session ID.

get_session_id() : \ID_TEXT
package core

Returns

\ID_TEXTThe current session ID (blank: none)

Get the site's default language, with support for URL overrides.

get_site_default_lang() : \LANGUAGE_NAME
package core

Returns

\LANGUAGE_NAMEThe site's default language

Get the site name.

get_site_name() : string
package core

Returns

stringThe name of the site

Get the site-wide salt. It should be something hard for a hacker to get, so we depend on data gathered both from the database and file-system.

get_site_salt() : \ID_TEXT
package core

Returns

\ID_TEXTThe salt

Get the timezone the site is running on.

get_site_timezone() : string
package core

Returns

stringSite timezone in "boring" format.

Get list of staff contextual actions.

get_staff_actions_list() : string
package core

Returns

stringThe list

Get a list of MySQL stopwords.

get_stopwords_list() : array
package core

Returns

arrayList of stopwords (actually a map of stopword to true)

Get syndication field UI.

get_syndication_option_fields() : \Tempcode
package core

Returns

\TempcodeSyndication fields (or empty)

Get the table prefixes used for all Composr tables, commonly used when you are installing Composr in the same database as your forums. The default table prefix is 'cms4_'. Note that anything that might write to an arbitrary db, must ask that db for it's table prefix (if it needs it of course.

get_table_prefix() : string

.. the db abstracts away most needs for it)

package core

Returns

stringThe table prefix

Read the contents of a template file.

get_template_contents(string $name) : string
package core

Parameters

$name

string

The name of the template (based on the filename)

Returns

stringThe contents of the file (blank if it does not exist)

Get the map of names/titles of the available templates.

get_templates_list() : array
package core

Returns

arrayThe names and titles of all available templates (title refers to the text within the first [title] tag in the template file)

Get a list of timezones.

get_timezone_list() : array
package core

Returns

arrayTimezone (map between boring-style and human-readable name). Sorted in offset order then likelihood orde.

Get a nice formatted date from the specified Unix timestamp.

get_timezoned_date(\TIME $timestamp, boolean $include_time = true, boolean $verbose = false, boolean $utc_time = false, boolean $avoid_contextual_dates = false, \?MEMBER $member = null) : string
package core

Parameters

$timestamp

\TIME

Input timestamp

$include_time

boolean

Whether to include the time in the output

$verbose

boolean

Whether to make this a verbose date (longer than usual)

$utc_time

boolean

Whether to work in UTC time

$avoid_contextual_dates

boolean

Whether contextual dates will be avoided

$member

\?MEMBER

Member for which the date is being rendered (null: current member)

Returns

stringFormatted time

Get a nice formatted time from the specified Unix timestamp.

get_timezoned_time(\TIME $timestamp, boolean $avoid_contextual_dates = false, \?MEMBER $member = null, boolean $utc_time = false) : string
package core

Parameters

$timestamp

\TIME

Input timestamp

$avoid_contextual_dates

boolean

Whether contextual times will be avoided. Note that we don't currently use contextual (relative) times. This parameter may be used in the future.

$member

\?MEMBER

Member for which the time is being rendered (null: current member)

$utc_time

boolean

Whether to work in UTC time

Returns

stringFormatted time

This function is an offshoot of get_translated_text, it instead returns parsed Comcode that is linked to the specified language ID.

get_translated_tempcode(\ID_TEXT $table, array $row, \ID_TEXT $field_name, \?object $connection = null, \?LANGUAGE_NAME $lang = null, boolean $force = false, boolean $as_admin = false, boolean $clear_away_from_cache = false) : \?Tempcode
package core

Parameters

$table

\ID_TEXT

The table name

$row

array

The table row. Must not have aspects of other tables in it (i.e. joins). Pre-filter using 'db_map_restrict' if required

$field_name

\ID_TEXT

The field name

$connection

\?object

The database connection to use (null: standard site connection)

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

$force

boolean

Whether to force it to the specified language

$as_admin

boolean

Whether to force as_admin, even if the lang string isn't stored against an admin (designed for Comcode page caching)

$clear_away_from_cache

boolean

Whether to remove from the Tempcode cache when we're done, for performance reasons (normally don't bother with this, but some code knows it won't be needed again -- esp Comcode cache layer -- and saves RAM by removing it)

Returns

\?TempcodeThe parsed Comcode (null: the text couldn't be looked up)

Wrapper for get_translated_tempcode, which then converts complex Tempcode back to very simple flat Tempcode, as an optimisation.

get_translated_tempcode__and_simplify(\ID_TEXT $table, array $row, \ID_TEXT $field_name, \?object $connection = null, \?LANGUAGE_NAME $lang = null, boolean $force = false, boolean $as_admin = false, boolean $clear_away_from_cache = false) : \?Tempcode

We won't normally call this as it breaks our architecture, but webmaster may request it if they are okay with it.

package core

Parameters

$table

\ID_TEXT

The table name

$row

array

The table row. Must not have aspects of other tables in it (i.e. joins). Pre-filter using 'db_map_restrict' if required

$field_name

\ID_TEXT

The field name

$connection

\?object

The database connection to use (null: standard site connection)

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

$force

boolean

Whether to force it to the specified language

$as_admin

boolean

Whether to force as_admin, even if the lang string isn't stored against an admin (designed for Comcode page caching)

$clear_away_from_cache

boolean

Whether to remove from the Tempcode cache when we're done, for performance reasons (normally don't bother with this, but some code knows it won't be needed again -- esp Comcode cache layer -- and saves RAM by removing it)

Returns

\?TempcodeThe parsed Comcode (null: the text couldn't be looked up)

Try to return the human-readable version of the language ID, passed in as $entry.

get_translated_text(mixed $entry, \?object $connection = null, \?LANGUAGE_NAME $lang = null, boolean $force = false) : \?string
package core

Parameters

$entry

mixed

The ID (if multi-lang-content on), or the string itself

$connection

\?object

The database connection to use (null: standard site connection)

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

$force

boolean

Whether to force it to the specified language

Returns

\?stringThe human-readable version (null: could not look up when $force was on)

Get the XML for transferring a language string.

get_translated_text_xml(\AUTO_LINK $id, \ID_TEXT $name, object $db) : string
package core

Parameters

$id

\AUTO_LINK

Language ID

$name

\ID_TEXT

The element name

$db

object

Database connection

Returns

stringXML (no root tag)

Returns a list of pairs, for which permissions are true by default for ordinary usergroups.

get_true_permissions() : array
package core

Returns

arrayList of pairs

Get a URL to a Composr tutorial.

get_tutorial_url(\ID_TEXT $tutorial) : \URLPATH
package core

Parameters

$tutorial

\ID_TEXT

Name of a tutorial

Returns

\URLPATHURL to a tutorial

In Tapatalk files may be passed as arrays, so abstract that complexity.

get_upload_filearray(\ID_TEXT $name, array $filearrays) 
package core

Parameters

$name

\ID_TEXT

The name of the HTTP file parameter storing the upload.

$filearrays

array

Where we are storing our file arrays.

Get the URL to the config option group for editing limits

get_upload_limit_config_url() : \?URLPATH
package core

Returns

\?URLPATHThe URL to the config option group for editing limits (null: no access)

Get details for what upload syndication we can do for particular filtered upload types.

get_upload_syndication_json(integer $file_handling_types) : array
package core

Parameters

$file_handling_types

integer

The kind of files we are going to be handling.

Returns

arrayA pair: JSON data describing what upload syndication we can do (may be NULL), a filetype filter.

Get URLs generated according to the specified information. It can also generate a thumbnail if required. It first tries attached upload, then URL, then fails.

get_url(\ID_TEXT $specify_name, \ID_TEXT $attach_name, \ID_TEXT $upload_folder, integer $obfuscate = 0, integer $enforce_type = 15, boolean $make_thumbnail = false, \ID_TEXT $thumb_specify_name = '', \ID_TEXT $thumb_attach_name = '', boolean $copy_to_server = false, boolean $accept_errors = false, boolean $should_get_something = false, boolean $only_make_smaller = false, \?MEMBER $member_id = null, \?PATH $upload_folder_full = null, \?PATH $thumb_folder_full = null, \?string $filename = null) : array
package core
set 0 1 2 3

Parameters

$specify_name

\ID_TEXT

The name of the POST parameter storing the URL (if '', then no POST parameter). Parameter value may be blank.

$attach_name

\ID_TEXT

The name of the HTTP file parameter storing the upload (if '', then no HTTP file parameter). No file necessarily is uploaded under this.

$upload_folder

\ID_TEXT

The folder name where we will put this upload

$obfuscate

integer

Whether to obfuscate file names so the URLs can not be guessed/derived (0=do not, 1=do, 2=make extension .dat as well, 3=only obfuscate if we need to)

$enforce_type

integer

The type of upload it is (bitmask, from CMSUPLOAD* constants)

$make_thumbnail

boolean

Make a thumbnail (this only makes sense, if it is an image)

$thumb_specify_name

\ID_TEXT

The name of the POST parameter storing the thumb URL. As before

$thumb_attach_name

\ID_TEXT

The name of the HTTP file parameter storing the thumb upload. As before

$copy_to_server

boolean

Whether to copy a URL (if a URL) to the server, and return a local reference

$accept_errors

boolean

Whether to accept upload errors

$should_get_something

boolean

Whether to give a (deferred?) error if no file was given at all

$only_make_smaller

boolean

Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images)

$member_id

\?MEMBER

Member ID to run permissions with (null: current member)

$upload_folder_full

\?PATH

Full path to upload folder, in case it is not relative to the base directory (null: work out)

$thumb_folder_full

\?PATH

Full path to thumb folder, in case it is not relative to the base directory (null: work out)

$filename

\?string

Filename to use (null: choose one)

Returns

arrayAn array of 4 URL bits (URL, thumb URL, URL original filename, thumb original filename)

Find Composr was installed to use persistent database connections or not.

get_use_persistent() : boolean
package core

Returns

booleanWhether to use persistent database connections

Get database rows of all the online members.

get_users_online(boolean $longer_time, \?MEMBER $filter, integer $count) : \?array
package core

Parameters

$longer_time

boolean

Whether to use a longer online-time -- the session expiry-time

$filter

\?MEMBER

We really only need to make sure we get the status for this user, although at this functions discretion more may be returned and the row won't be there if the user is not online (null: no filter). May not be the guest ID

$count

integer

The total online members, returned by reference

Returns

\?arrayDatabase rows (null: too many)

Get a user's timezone.

get_users_timezone(\?MEMBER $member = null) : string
package core

Parameters

$member

\?MEMBER

Member for which the date is being rendered (null: current user)

Returns

stringUsers timezone in "boring" format.

Find a specified value. Values are set with set_value.

get_value(\ID_TEXT $name, \?ID_TEXT $default = null, boolean $elective_or_lengthy = false, boolean $env_also = false) : \?SHORT_TEXT
package core

Parameters

$name

\ID_TEXT

The name of the value

$default

\?ID_TEXT

Value to return if value not found (null: return NULL)

$elective_or_lengthy

boolean

Whether this value is an elective/lengthy one. Use this for getting & setting if you don't want it to be loaded up in advance for every page view (in bulk alongside other values), or if the value may be more than 255 characters. Performance tradeoff: frequently used values should not be elective, infrequently used values should be elective.

$env_also

boolean

Whether to also check server environmental variables. Only use if $elective_or_lengthy is set to false

Returns

\?SHORT_TEXTThe value (null: value not found and default is NULL)

Find the specified configuration option if it is younger than a specified time.

get_value_newer_than(\ID_TEXT $name, \TIME $cutoff, boolean $elective_or_lengthy = false) : \?SHORT_TEXT
package core

Parameters

$name

\ID_TEXT

The name of the value

$cutoff

\TIME

The cutoff time (an absolute time, not a relative "time ago")

$elective_or_lengthy

boolean

Whether this value is an elective/lengthy one. Use this for getting & setting if you don't want it to be loaded up in advance for every page view (in bulk alongside other values), or if the value may be more than 255 characters. Performance tradeoff: frequently used values should not be elective, infrequently used values should be elective.

Returns

\?SHORT_TEXTThe value (null: value newer than not found)

Get branch version number for a Composr version.

get_version_branch(\?float $general = null) : string
package core

Parameters

$general

\?float

General version number (null: on disk version)

Returns

stringBranch version number (null: on disk version)

Analyse a dotted version number into components.

get_version_components__from_dotted(string $dotted) : array
package core

Parameters

$dotted

string

Dotted version number

Returns

arrayTuple of components: dotted basis version (i.e. with no alpha/beta/RC component and no trailing zeros), qualifier (blank, or alpha, or beta, or RC), qualifier number (NULL if not an alpha/beta/RC), dotted version number with trailing zeros to always cover 3 components

Get dotted version from given Composr-version-registry (version.php) supplied components.

get_version_dotted(\?integer $main = null, \?string $minor = null) : string
package core

Parameters

$main

\?integer

Main version number (null: on disk version)

$minor

\?string

Minor version number (null: on disk version)

Returns

stringDotted version number

Gets any random way of writing a version number (in all of Composr's history) and makes it a dotted style like "3.2.beta2".

get_version_dotted__from_anything(string $any_format) : string

Note that the dotted format is compatible with PHP's version_compare function.

package core

Parameters

$any_format

string

Any reasonable input

Returns

stringPretty version number

Get a pretty version number for a Composr version.

get_version_pretty__from_dotted(string $pretty) : string

This pretty style is not used in Composr code per se, but is shown to users and hence Composr may need to recognise it when searching news posts, download databases, etc.

package core

Parameters

$pretty

string

Pretty version number

Returns

stringDotted version number

Extract meta details from a URL.

get_webpage_meta_details(\URLPATH $url) : array
package core

Parameters

$url

\URLPATH

Webpage URL

Returns

arrayA map of meta details extracted from the webpage

Lookup error on compo.sr, to see if there is more information.

get_webservice_result(mixed $error_message) : \?string
package core

Parameters

$error_message

mixed

The error message (string or Tempcode)

Returns

\?stringThe result from the web service (null: no result)

Get XML definition of common entities we may use.

get_xml_entities() : string
package core

Returns

stringXML

Get a zone chooser interface.

get_zone_chooser(boolean $inline = false, \?array $no_go = null, \?array $reorder = null) : \Tempcode
package core

Parameters

$inline

boolean

Whether the zone chooser will be shown inline to something else (as opposed to providing it's own borderings)

$no_go

\?array

A list of zone to not put into the list (null: none to skip)

$reorder

\?array

A reordering (null: no reordering)

Returns

\TempcodeThe zone chooser

Get the default page for a zone.

get_zone_default_page(\ID_TEXT $zone_name) : \ID_TEXT
package core

Parameters

$zone_name

\ID_TEXT

Zone name

Returns

\ID_TEXTDefault page

Get the name of the zone the current page request is coming from.

get_zone_name() : \ID_TEXT
package core

Returns

\ID_TEXTThe current zone

Give points to a member for submitting something, then returns the XHTML page to say so.

give_submit_points(\ID_TEXT $type, \?MEMBER $member = null) : \?string
package core

Parameters

$type

\ID_TEXT

One of this type has been submitted. By convention it is the language code of what was done, e.g. ADD_DOWNLOAD

$member

\?MEMBER

The member to give the points to (null: give to current member)

Returns

\?stringA message about the member being given these submit points (null: no message)

Turn the Tempcode lump into a standalone page.

globalise(\?Tempcode $middle, \?mixed $message = null, string $type = '', boolean $include_header_and_footer = false) : \Tempcode
package core
set inform warn ""

Parameters

$middle

\?Tempcode

The Tempcode to put into a nice frame (null: support output streaming mode)

$message

\?mixed

'Additional' message (null: none)

$type

string

The type of special message

$include_header_and_footer

boolean

Whether to include the header/footer/panels

Returns

\TempcodeStandalone page

Process a logout.

handle_active_logout() 
package core

Use the url_title_cache table (a bit of a hack but saved changed the DB structure) to see if a check-op was performed has been performed within the last 30 days.

handle_has_checked_recently(\ID_TEXT $id_code) : boolean
package core

Parameters

$id_code

\ID_TEXT

Special check code (often a URL but does not need to be).

Returns

booleanWhether the check has happened recently.

Handles an attempted login or logout, and take care of all the sessions and cookies etc.

handle_logins() 
package core

Deal with a perceived spammer.

handle_perceived_spammer_by_confidence(\IP $user_ip, float $confidence_level, \ID_TEXT $blocked_by, boolean $page_level) 
package core

Parameters

$user_ip

\IP

IP address

$confidence_level

float

Confidence level (0.0 to 1.0)

$blocked_by

\ID_TEXT

Identifier for whatever did the blocking

$page_level

boolean

Whether this is a page level check (i.e. we won't consider blocks or approval, just ban setting)

Log permission checks to the permission_checks.log file, if it exists.

handle_permission_check_logging(\MEMBER $member, \ID_TEXT $op, array $params, boolean $result) 
package core

Parameters

$member

\MEMBER

The user checking against

$op

\ID_TEXT

The function that was called to check a permission

$params

array

Parameters to this permission-checking function

$result

boolean

Whether the permission was held

Certain symbols need preprocessing, before the output stream is made.

handle_symbol_preprocessing(array $seq_part, array $children) 
package core

Parameters

$seq_part

array

Symbol details

$children

array

Where we store children stuff

Do upload syndication (after an upload has been received, in-context).

handle_upload_syndication(\ID_TEXT $name, string $title, string $description, \URLPATH $url, \ID_TEXT $filename, boolean $remove_locally_if_no_quota) : \URLPATH
package core

Parameters

$name

\ID_TEXT

Upload field name.

$title

string

Title associated with the upload.

$description

string

Description associated with the upload.

$url

\URLPATH

URL to the upload (should be local, if it isn't we'll return quickly without doing anything).

$filename

\ID_TEXT

Filename.

$remove_locally_if_no_quota

boolean

Whether to delete the local copy, if the current user has no upload quota. If no syndication was set, an error will be given.

Returns

\URLPATHNew URL (if we deleted the local copy, it will be a remote URL).

Filter input data for safety within potential filesystem calls.

hard_filter_input_data__filesystem(string $val) 

Only called for non-privileged users, filters/alters rather than blocks, due to false-positive likelihood.

package core

Parameters

$val

string

The data

Filter input data for safety within frontend markup, taking account of HTML/JavaScript/CSS/embed attacks.

hard_filter_input_data__html(string $val) 

Only called for non-privileged users, filters/alters rather than blocks, due to false-positive likelihood.

package core

Parameters

$val

string

The data

Find if a member has access to a specified page. Zone permissions are taken into account for wherever the page is found at. Also support for category access and privileges. No support for entry-point checks, which are only carried out as an extension of page permissions when actually at a page.

has_actual_page_access(\?MEMBER $member = null, \?ID_TEXT $page = null, \?ID_TEXT $zone = null, \?array $cats = null, \?mixed $privilege = null) : boolean
package core

Parameters

$member

\?MEMBER

The member being checked whether to have the access (null: current member)

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$zone

\?ID_TEXT

The ID code for the zone being checked (null: search)

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

$privilege

\?mixed

Either the ID code of a privilege, an array of alternatives that are acceptable (null: none required)

Returns

booleanWhether the member has zone and page access

Check to see if a member has add permission for Comcode pages

has_add_comcode_page_permission(\?ID_TEXT $zone = null, \?MEMBER $member = null) : boolean
package core

Parameters

$zone

\?ID_TEXT

The zone of Comcode pages we need it in (null: ANY zone, we are doing a vague check if the user could possibly)

$member

\?MEMBER

The member being checked for access (null: current member)

Returns

booleanIf the permission is there

Check to see if a member has bypass-validation permission for Comcode pages

has_bypass_validation_comcode_page_permission(\?ID_TEXT $zone = null, \?MEMBER $member = null) : boolean
package core

Parameters

$zone

\?ID_TEXT

The zone of Comcode pages we need it in (null: ANY zone, we are doing a vague check if the user could possibly)

$member

\?MEMBER

The member being checked for access (null: current member)

Returns

booleanIf the permission is there

Check to see if caching is enabled.

has_caching_for(string $type) : boolean
package core
set block lang comcode_page template

Parameters

$type

string

Cache type

Returns

booleanWhether it has the caching

Find if a member has access to a specified category

has_category_access(\MEMBER $member, \ID_TEXT $module, \ID_TEXT $category) : boolean
package core

Parameters

$member

\MEMBER

The member being checked whether to have the access

$module

\ID_TEXT

The ID code for the module being checked for category access

$category

\ID_TEXT

The ID code for the category being checked for access (often, a number cast to a string)

Returns

booleanWhether the member has category access

Determine whether the user's browser supports cookies or not.

has_cookies() : boolean

Unfortunately this function will only return true once a user has been to the site more than once... Composr will set a cookie, and if it perseveres, that indicates cookies work.

package core

Returns

booleanWhether the user has definitely got cookies

Check to see if a member has permission to delete a specific resource

has_delete_permission(string $range, \MEMBER $member, \?MEMBER $resource_owner, \?ID_TEXT $page, \?array $cats = null) : boolean
package core
set low mid high cat_low cat_mid cat_high

Parameters

$range

string

The range of permission we are checking to see if they have; these ranges are like trust levels

$member

\MEMBER

The member being checked for access

$resource_owner

\?MEMBER

The member that owns this resource (null: no-one)

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

Returns

booleanWhether the member may delete the resource

Check to see if a member has permission to edit a specific Comcode page

has_edit_comcode_page_permission(\ID_TEXT $zone, \ID_TEXT $page, \?MEMBER $owner = null, \?MEMBER $member = null) : boolean
package core

Parameters

$zone

\ID_TEXT

The zone of the page

$page

\ID_TEXT

The name of the page

$owner

\?MEMBER

Owner of the page (null: look it up)

$member

\?MEMBER

The member being checked for access (null: current member)

Returns

booleanIf the permission is there

Find if a member has permission to edit

has_edit_permission(string $range, \MEMBER $member, \?MEMBER $resource_owner, \?ID_TEXT $page, \?array $cats = null) : boolean
package core
set low mid high cat_low cat_mid cat_high

Parameters

$range

string

The range of permission we are checking to see if they have; these ranges are like trust levels

$member

\MEMBER

The member being checked for access

$resource_owner

\?MEMBER

The member that owns this resource (null: no-one)

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

Returns

booleanWhether the member may edit the resource

Check all strings within a query were properly escaped (by checking log of what we escaped).

has_escaped_dynamic_sql(string $query) : boolean
package core

Parameters

$query

string

The query

Returns

booleanWhether it is all good

Detect whether we have external site-wide syndication support somewhere.

has_external_site_wide_syndication() : boolean
package core

Returns

booleanWhether we do

Determine whether the user's browser supports JavaScript or not.

has_js() : boolean

Unfortunately this function will only return true once a user has been to the site more than once... JavaScript will set a cookie, indicating it works.

package core

Returns

booleanWhether the user has definitely got JavaScript

Find whether we have no forum on this website.

has_no_forum() : boolean
package core

Returns

booleanWhether we have no forum on this website

Find if a member has access to a specified page, in a specific zone. Note that page access does not imply zone access; you have access a page, but not the zone, so still couldn't see it.

has_page_access(\MEMBER $member, \ID_TEXT $page, \ID_TEXT $zone, boolean $at_now = false) : boolean
package core

Parameters

$member

\MEMBER

The member being checked whether to have the access

$page

\ID_TEXT

The ID code for the page being checked

$zone

\ID_TEXT

The ID code for the zone being checked

$at_now

boolean

Whether we want to check we have access to the CURRENT page, using any match-key permissions

Returns

booleanWhether the member has page access

Find if a member has a specified permission

has_privilege(\MEMBER $member, \ID_TEXT $permission, \?ID_TEXT $page = null, \?mixed $cats = null) : boolean
package core

Parameters

$member

\MEMBER

The member being checked whether to have the permission

$permission

\ID_TEXT

The ID code for the permission being checked for

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$cats

\?mixed

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...), or a string of the cat type if you will accept overrides in any matching cat (null: N/A)

Returns

booleanWhether the member has the permission

Find if a group has a specified permission

has_privilege_group(\GROUP $group_id, \ID_TEXT $permission, \?ID_TEXT $page = null, \?array $cats = null) : boolean
package core

Parameters

$group_id

\GROUP

The being checked whether to have the permission

$permission

\ID_TEXT

The ID code for the permission being checked for

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

Returns

booleanWhether the member has the permission

Find if a security property has been declared as being understood.

has_solemnly_declared(integer $declaration) : boolean
package core

Parameters

$declaration

integer

The property.

Returns

booleanWhether it is understood.

Find if a member has a specified permission in any category

has_some_cat_privilege(\MEMBER $member, \ID_TEXT $permission, \?ID_TEXT $page, \ID_TEXT $permission_module) : boolean
package core

Parameters

$member

\MEMBER

The member being checked whether to have the permission

$permission

\ID_TEXT

The ID code for the permission being checked for

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$permission_module

\ID_TEXT

The ID code for the permission module being checked for

Returns

booleanWhether the member has the permission

Check to see if a member has permission to edit a Comcode page

has_some_edit_comcode_page_permission(integer $scope, \?ID_TEXT $zone = null, \?MEMBER $member = null) : boolean
package core

Parameters

$scope

integer

A bitmask of COMCODEEDIT* constants, identifying what kind of editing permission we are looking for

$zone

\?ID_TEXT

Zone to check for (null: check against global privileges, ignoring all per-zone overrides). Note how this is different to how a NULL zone works for checking add/bypass-validation permissions because if we get a false we have the get_comcode_page_editability_per_zone function to get more specific details, while for adding we either want a very specific or very vague answer.

$member

\?MEMBER

The member being checked for access (null: current member)

Returns

booleanIf the permission is there

Find if a member has permission to submit

has_submit_permission(string $range, \MEMBER $member, \IP $ip, \?ID_TEXT $page, \?array $cats = null) : boolean
package core
set low mid high cat_low cat_mid cat_high

Parameters

$range

string

The range of permission we are checking to see if they have; these ranges are like trust levels

$member

\MEMBER

The member being checked whether to have the access

$ip

\IP

The member's IP address

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$cats

\?array

A list of cat details to require access to (c-type-1,c-id-1,c-type-2,c-d-2,...) (null: N/A)

Returns

booleanWhether the member can submit in this range

Find if a member has access to a specified zone

has_zone_access(\MEMBER $member, \ID_TEXT $zone) : boolean
package core

Parameters

$member

\MEMBER

The member being checked whether to have the access

$zone

\ID_TEXT

The ID code for the zone being checked

Returns

booleanWhether the member has zone access

Include some PHP code, compiling to HHVM's hack, for type strictness (uses Composr phpdoc comments).

hhvm_include(\PATH $path) : \?mixed
package core

Parameters

$path

\PATH

Include path

Returns

\?mixedCode return code (null: actual NULL)

Function that tucks-under-the-carpet lumps of XHTML that knowingly won't conform to XHTML5.

hide_the_evidence(\Tempcode $html) : \Tempcode
package core

Parameters

$html

\Tempcode

What to hide away

Returns

\TempcodeHidden away version

Return the file in the URL by downloading it over HTTP. If a byte limit is given, it will only download that many bytes. It outputs warnings, returning NULL, on error.

http_download_file(\URLPATH $url, \?integer $byte_limit = null, boolean $trigger_error = true, boolean $no_redirect = false, string $ua = 'Composr', \?array $post_params = null, \?array $cookies = null, \?string $accept = null, \?string $accept_charset = null, \?string $accept_language = null, \?resource $write_to_file = null, \?string $referer = null, \?array $auth = null, float $timeout = 6.0, boolean $raw_post = false, \?array $files = null, \?array $extra_headers = null, \?string $http_verb = null, string $raw_content_type = 'application/xml') : \?string
package core
range 1 max

Parameters

$url

\URLPATH

The URL to download

$byte_limit

\?integer

The number of bytes to download. This is not a guarantee, it is a minimum (null: all bytes)

$trigger_error

boolean

Whether to throw a Composr error, on error

$no_redirect

boolean

Whether to block redirects (returns NULL when found)

$ua

string

The user-agent to identify as

$post_params

\?array

An optional array of POST parameters to send; if this is NULL, a GET request is used (null: none)

$cookies

\?array

An optional array of cookies to send (null: none)

$accept

\?string

'accept' header value (null: don't pass one)

$accept_charset

\?string

'accept-charset' header value (null: don't pass one)

$accept_language

\?string

'accept-language' header value (null: don't pass one)

$write_to_file

\?resource

File handle to write to (null: do not do that)

$referer

\?string

The HTTP referer (null: none)

$auth

\?array

A pair: authentication username and password (null: none)

$timeout

float

The timeout

$raw_post

boolean

Whether to treat the POST parameters as a raw POST (rather than using MIME)

$files

\?array

Files to send. Map between field to file path (null: none)

$extra_headers

\?array

Extra headers to send (null: none)

$http_verb

\?string

HTTP verb (null: auto-decide based on other parameters)

$raw_content_type

string

The content type to use if a raw HTTP post

Returns

\?stringThe data downloaded (null: error)

Declare what security properties the programmer understands. i.e. Self-certification.

i_solemnly_declare(integer $declarations) 

A good programmer will understand the correct data conversions to undergo in order to write secure/correct/reliable code. A newbie programmer likely will not, sloppiness or a lack of understanding could lead to critical mistakes. If declarations aren't made then extra security precautions are taken, which may interfere with normal processing in limited cases. Declarations should be made whenever entering a custom block or module.

package core

Parameters

$declarations

integer

Bitmask of declarations (IUNDERSTAND* constants).

Import to Composr database table from the equivalent XML format.

import_from_xml(string $xml_data, boolean $delete_missing_rows = false) : array
package core

Parameters

$xml_data

string

Data in XML format

$delete_missing_rows

boolean

Synchronise deletes as well as inserts/updates

Returns

arrayList of operations performed

Complain about a field being missing.

improperly_filled_in(string $name, \?boolean $posted, array $array) 
package core

Parameters

$name

string

The name of the parameter

$posted

\?boolean

Whether the parameter is a POST parameter (null: undetermined)

$array

array

The array we're extracting parameters from

Complain about a POST field being missing.

improperly_filled_in_post(string $name) 
package core

Parameters

$name

string

The name of the parameter

Perform a database-style in-memory boolean search on single item.

in_memory_search_match(array $filter, string $title, \?string $post = null) : boolean
package core

Parameters

$filter

array

A map of POST data in search-form style. May contain 'only_titles', 'content' (the critical one!) and 'conjunctive_operator'

$title

string

The title to try and match

$post

\?string

The post to try and match (null: not used)

Returns

booleanWhether we have a match

Find whether we are running in safe mode.

in_safe_mode() : boolean
package core

Returns

booleanWhether we are in safe mode

Function to process the file upload process

incoming_uploads_script() 
package core

This is a intended to output an informational exit at the same time as terminating execution

inform_exit(mixed $text, \?boolean $support_match_key_messages = null) : mixed
package core

Parameters

$text

mixed

The error message (string or Tempcode)

$support_match_key_messages

\?boolean

Whether match key messages / redirects should be supported (null: detect)

Returns

mixedNever returns (i.e. exits)

Mark another parameter non-canonical, so that Google won't consider it when indexing URLs.

inform_non_canonical_parameter(\ID_TEXT $param) 
package core
sets_output_state

Parameters

$param

\ID_TEXT

Parameter name

Get the Tempcode for an info page.

inform_screen(\Tempcode $title, mixed $text, boolean $support_match_key_messages = false, \?Tempcode $back_url = null, \?Tempcode $fields = null) : \Tempcode
package core

Parameters

$title

\Tempcode

The title of the info page

$text

mixed

The text to put on the info page (string, or language-Tempcode)

$support_match_key_messages

boolean

Whether match key messages / redirects should be supported

$back_url

\?Tempcode

URL to have back button to (null: none)

$fields

\?Tempcode

Fields to carry with on back button (null: none)

Returns

\TempcodeThe info page

Initialise state variables for the special page type being requested.

initialise_special_page_types(\ID_TEXT $special_page_type) 
package core
set query templates tree lang

Parameters

$special_page_type

\ID_TEXT

The special page type.

Should be called when an action happens that results in content submission. Does a spammer check.

inject_action_spamcheck(\?string $username = null, \?string $email = null
package core

Parameters

$username

\?string

Check this particular username that has just been supplied (null: none)

$email

\?string

Check this particular email address that has just been supplied (null: none)

Edit a language string direct from something saved into the code.

inline_language_editing(\ID_TEXT $codename, \?LANGUAGE_NAME $lang) 
package core

Parameters

$codename

\ID_TEXT

The language ID

$lang

\?LANGUAGE_NAME

The language to use (null: users language)

Insert some code into a function in the given code snippet, by command (after command).

insert_code_after__by_command(string $code, string $function, string $command, string $newcode, integer $instance_of_command = 1) : boolean
package core

Parameters

$code

string

The code.

$function

string

Name of the function.

$command

string

The command we're searching to insert by.

$newcode

string

Code to insert.

$instance_of_command

integer

We are inserting at this instance of the line (i.e. takes into account a literal line of code may exist in other places in a function).

Returns

booleanSuccess status.

Insert some code into a function in the given code snippet, by command (before command).

insert_code_before__by_command(string $code, string $function, string $command, string $newcode, integer $instance_of_command = 1) : boolean
package core

Parameters

$code

string

The code.

$function

string

Name of the function.

$command

string

The command we're searching to insert by.

$newcode

string

Code to insert.

$instance_of_command

integer

We are inserting at this instance of the line (i.e. takes into account a literal line of code may exist in other places in a function).

Returns

booleanSuccess status.

Insert a language entry into the translation table, and returns the ID.

insert_lang(\ID_TEXT $field_name, string $text, integer $level, \?object $connection = null, boolean $comcode = false, \?integer $id = null, \?LANGUAGE_NAME $lang = null, boolean $insert_as_admin = false, \?string $pass_id = null, \?string $text_parsed = null, \?integer $wrap_pos = null, boolean $preparse_mode = true, boolean $save_as_volatile = false) : array
package core
set 1 2 3 4

Parameters

$field_name

\ID_TEXT

The field name

$text

string

The text

$level

integer

The level of importance this language string holds

$connection

\?object

The database connection to use (null: standard site connection)

$comcode

boolean

Whether it is to be parsed as Comcode

$id

\?integer

The ID to use for the language entry (null: work out next available)

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

$insert_as_admin

boolean

Whether to insert it as an admin (any Comcode parsing will be carried out with admin privileges)

$pass_id

\?string

The special identifier for this lang code on the page it will be displayed on; this is used to provide an explicit binding between languaged elements and greater templated areas (null: none)

$text_parsed

\?string

Assembled Tempcode portion (null: work it out)

$wrap_pos

\?integer

Comcode parser wrap position (null: no wrapping)

$preparse_mode

boolean

Whether to generate a fatal error if there is invalid Comcode

$save_as_volatile

boolean

Whether we are saving as a 'volatile' file extension (used in the XML DB driver, to mark things as being non-syndicated to subversion)

Returns

arrayThe language ID save fields

Insert a Comcode language entry into the translation table, and returns the ID.

insert_lang_comcode(\ID_TEXT $field_name, string $text, integer $level, \?object $connection = null, boolean $insert_as_admin = false, \?string $pass_id = null, \?integer $wrap_pos = null, boolean $preparse_mode = true, boolean $save_as_volatile = false) : array
package core
set 1 2 3 4

Parameters

$field_name

\ID_TEXT

The field name

$text

string

The text

$level

integer

The level of importance this language string holds

$connection

\?object

The database connection to use (null: standard site connection)

$insert_as_admin

boolean

Whether to insert it as an admin (any Comcode parsing will be carried out with admin privileges)

$pass_id

\?string

The special identifier for this lang code on the page it will be displayed on; this is used to provide an explicit binding between languaged elements and greater templated areas (null: none)

$wrap_pos

\?integer

Comcode parser wrap position (null: no wrapping)

$preparse_mode

boolean

Whether to generate a fatal error if there is invalid Comcode

$save_as_volatile

boolean

Whether we are saving as a 'volatile' file extension (used in the XML DB driver, to mark things as being non-syndicated to subversion)

Returns

arrayThe language ID save fields

Parse some text for language string values, and insert.

insert_lang_xml(\ID_TEXT $field_name, string $xml_data) : array
package core

Parameters

$field_name

\ID_TEXT

The field name

$xml_data

string

XML (with root tag), or just flat text if multi-lang-content is not on

Returns

arrayThe language ID save fields

Output whatever arguments are given for debugging. If possible it'll output with plain text, but if output has already started it will attach messages.

inspect() 
package core

Output whatever arguments are given for debugging as text and exit. If possible it'll output with plain text, but if output has already started it will attach messages.

inspect_plain() 
package core

Format the given integer number as a nicely formatted string.

integer_format(integer $val) : string
package core

Parameters

$val

integer

The value to format

Returns

stringNicely formatted string

Discern the cause of a file-write error, and show an appropriate error message.

intelligent_write_error(\PATH $path) 
package core

Parameters

$path

\PATH

File path that could not be written (full path, not relative)

Discern the cause of a file-write error, and return an appropriate error message.

intelligent_write_error_inline(\PATH $path) : \Tempcode
package core

Parameters

$path

\PATH

File path that could not be written

Returns

\TempcodeMessage

Very simple function to invert the meaning of an old hidden option. We often use this when we've promoted a hidden option into a new proper option but inverted the meaning in the process - we use this in the default value generation code, as an in-line aid to preserve existing hidden option settings.

invert_value(\ID_TEXT $old) : \ID_TEXT
package core
set 0 1

Parameters

$old

\ID_TEXT

The old value

Returns

\ID_TEXTThe inverted value

Check to see if an IP address is banned.

ip_banned(string $ip, boolean $force_db = false, boolean $handle_uncertainties = false) : \?boolean
package core

Parameters

$ip

string

The IP address to check for banning (potentially encoded with *'s)

$force_db

boolean

Force check via database

$handle_uncertainties

boolean

Handle uncertainities (used for the external bans - if true, we may return NULL, showing we need to do an external check). Only works with $force_db.

Returns

\?booleanWhether the IP address is banned (null: unknown)

Find if an IP address is within a CIDR range. Based on comment in PHP manual: http://php.net/manual/en/ref.network.php

ip_cidr_check(\IP $ip, \SHORT_TEXT $cidr) : boolean
package core

Parameters

$ip

\IP

IP address

$cidr

\SHORT_TEXT

CIDR range (e.g. 204.93.240.0/24)

Returns

booleanWhether it is

Find whether the specified string is alphanumeric or not.

is_alphanumeric(string $string, boolean $strict = false) : boolean
package core

Parameters

$string

string

The string to test

$strict

boolean

Whether to do stricter sanitisation

Returns

booleanWhether the string is alphanumeric or not

Find if we a string is ASCII, and hence we can use non-UTF-safe functions on it.

is_ascii_string(string $x) : boolean
package core

Parameters

$x

string

String to test

Returns

booleanWhether it is ASCII

Find whether the video specified is actually a 'video', based on file extension

is_audio(string $name, boolean $as_admin) : boolean
package core

Parameters

$name

string

A URL or file path to the video

$as_admin

boolean

Whether there are admin privileges, to render dangerous media types (client-side risk only)

Returns

booleanWhether the string pointed to a file appeared to be an audio file

Find whether the browser session is set to be doing a hard cache-empty refresh.

is_browser_decaching() : boolean
package core

Returns

booleanWhether the browser session is set to be doing a hard cache-empty refresh

Find if we're on an Conversr satellite site.

is_cns_satellite_site() : boolean
package core

Returns

booleanIf we are

Determine if some data has already been encrypted: i.e. if it has a magic encryption marker.

is_data_encrypted(string $data) : boolean
package core

Parameters

$data

string

Data to check

Returns

booleanEncrypted?

Find whether the specified address is a well-formed e-mail address or not.

is_email_address(string $string) : boolean
package core

Parameters

$string

string

The string to test (Note: This is typed string, not e-mail, because it has to function on failure + we could make an infinite loop)

Returns

booleanWhether the string is an email address or not

Determine whether the necessary PHP extensions to support encryption are available. For normal use, you should probably use is_encryption_enabled() instead.

is_encryption_available() : boolean
package core

Returns

booleanEncryption available?

Determine whether encryption support is available and enabled in the site's preferences, and the keys are in place.

is_encryption_enabled() : boolean
package core

Returns

booleanEncryption enabled?

Find whether a database connection is to the forum database.

is_forum_db(object $db) : boolean
package core

Parameters

$db

object

The DB connection to check against

Returns

booleanWhether we are

Find whether the current member is a guest.

is_guest(\?MEMBER $member_id = null, boolean $quick_only = false) : boolean
package core

Parameters

$member_id

\?MEMBER

Member ID to check (null: current user)

$quick_only

boolean

Whether to just do a quick check, don't establish new sessions

Returns

booleanWhether the current member is a guest

Find whether the image specified is actually an image, based on file extension

is_image(string $name, boolean $mime_too = false) : boolean
package core

Parameters

$name

string

A URL or file path to the image

$mime_too

boolean

Whether to check mime too

Returns

booleanWhether the string pointed to a file appeared to be an image

Find whether the current user is invisible.

is_invisible() : boolean
package core

Returns

booleanWhether the current user is invisible

Find if an e-mail address is bounced.

is_mail_bounced(\EMAIL $email, \?string $server = null, \?integer $port = null, \?string $folder = null, \?string $username = null, \?string $password = null) : \?TIME
package core

Parameters

$email

\EMAIL

The email address.

$server

\?string

The IMAP server hostname (null: use configured).

$port

\?integer

The IMAP port (null: use configured).

$folder

\?string

The IMAP inbox identifier (null: use configured).

$username

\?string

The IMAP username (null: use configured).

$password

\?string

The IMAP password (null: use configured).

Returns

\?TIMELast bounce time (null: not bounced).

Find whether the video specified is actually a 'video', based on file extension

is_media(string $name, boolean $as_admin) : boolean
package core

Parameters

$name

string

A URL or file path to the video

$as_admin

boolean

Whether there are admin privileges, to render dangerous media types (client-side risk only)

Returns

booleanWhether the string pointed to a file appeared to be an audio file

Look at the user's browser, and decide if they are viewing on a mobile device or not.

is_mobile(\?string $user_agent = null, boolean $truth = false) : boolean
package core

Parameters

$user_agent

\?string

The user agent (null: get from environment, current user's browser)

$truth

boolean

Whether to always tell the truth (even if the current page does not have mobile support)

Returns

booleanWhether the user is using a mobile device

Find whether we are on a multi-site-network.

is_on_multi_site_network(\?object $db = null) : boolean
package core

Parameters

$db

\?object

The DB connection to check against (null: main active site database)

Returns

booleanWhether we are

Find whether the specified page is to use HTTPS (if not -- it will use HTTP).

is_page_https(\ID_TEXT $zone, \ID_TEXT $page) : boolean

All images (etc) on a HTTPS page should use HTTPS to avoid mixed-content browser notices.

package core

Parameters

$zone

\ID_TEXT

The zone the page is in

$page

\ID_TEXT

The page codename

Returns

booleanWhether the page is to run across an HTTPS connection

Find whether an plupload upload has just happened, and optionally simulate as if it were a normal upload (although 'is_uploaded_file'/'move_uploaded_file' would not work).

is_plupload(boolean $fake_prepopulation = false) : boolean
package core

Parameters

$fake_prepopulation

boolean

Simulate population of the $_FILES array.

Returns

booleanWhether an plupload upload has just happened.

Use the image extension to determine if the specified image is of a format (extension) saveable by Composr or not.

is_saveable_image(string $name) : boolean
package core

Parameters

$name

string

A URL or file path to the image

Returns

booleanWhether the string pointed to a file that appeared to be a saveable image

Find if a query is a simple one involving 'AND' maps.

is_simple_query(string $query) : boolean
package core

Parameters

$query

string

The query

Returns

booleanWhether it is simple

Find whether we can get away with natural file access, not messing with AFMs, world-writability, etc.

is_suexec_like() : boolean
package core

Returns

booleanWhether we have this

Find whether an IP address is valid

is_valid_ip(\IP $ip) : boolean
package core

Parameters

$ip

\IP

IP address to check.

Returns

booleanWhether the IP address is valid.

Find whether the video specified is actually a 'video', based on file extension

is_video(string $name, boolean $as_admin, boolean $must_be_true_video = false) : boolean
package core

Parameters

$name

string

A URL or file path to the video

$as_admin

boolean

Whether there are admin privileges, to render dangerous media types (client-side risk only)

$must_be_true_video

boolean

Whether it really must be an actual video/audio, not some other kind of rich media which we may render in a video spot

Returns

booleanWhether the string pointed to a file appeared to be a video

Find whether panels will be shown.

is_wide() : \BINARY
package core

Returns

\BINARYResult.

Find whether panels and the header/footer areas won't be shown.

is_wide_high() : \BINARY
package core

Returns

\BINARYResult.

Find whether a file/directory is writeable. This function is designed to get past that the PHP is_writable function does not work properly on Windows.

is_writable_wrap(\PATH $path) : boolean
package core

Parameters

$path

\PATH

The file path

Returns

booleanWhether the file is writeable

Force a JavaScript file to be cached (ordinarily we can rely on this to be automated by require_javascript/javascript_tempcode).

javascript_enforce(string $j, \?ID_TEXT $theme = null, \?boolean $minify = null) : string
package core

Parameters

$j

string

The javascript file required

$theme

\?ID_TEXT

The name of the theme (null: current theme)

$minify

\?boolean

Whether to minify (null: read from environment)

Returns

stringThe path to the javascript file in the cache (blank: no file)

Get Tempcode to tie in (to the HTML, in <head>) all the JavaScript files that have been required.

javascript_tempcode(\?string $position = null) : \Tempcode
package core
set NULL header footer

Parameters

$position

\?string

Position to get JavaScript for (null: all positions)

Returns

\TempcodeThe Tempcode to tie in the JavaScript files

Compile a JavaScript file.

js_compile(\ID_TEXT $j, \PATH $js_cache_path, boolean $minify = true
package core

Parameters

$j

\ID_TEXT

Name of the JS file

$js_cache_path

\PATH

Full path to the JS file

$minify

boolean

Whether to also do minification

Minimise the given JavaScript

js_minify(string $js) : string
package core

Parameters

$js

string

JavaScript to minimise

Returns

stringMinimised JavaScript

String to tack onto URL to keep 'keep_' parameters.

keep_symbol(array $param) : string
package core

Parameters

$param

array

Parameters passed to the symbol (0=whether this starts off the query string, 1=force session append even if it's also available a session cookie e.g. when put into download manager)

Returns

stringThe result.

Provide automatic escaping for a template call.

kid_gloves_html_escaping(array $parameters) 
package core

Parameters

$parameters

array

Template parameters

Provide automatic escaping for a particular parameter.

kid_gloves_html_escaping_singular(string $param) 
package core

Parameters

$param

string

Parameter

Convert the specified language codename to the default content, and return the language key.

lang_code_to_default_content(\ID_TEXT $field_name, \ID_TEXT $code, boolean $comcode = false, integer $level = 2) : array
package core

Parameters

$field_name

\ID_TEXT

The field name

$code

\ID_TEXT

The language codename

$comcode

boolean

Whether the given codes value is to be parsed as Comcode

$level

integer

The level of importance this language string holds

Returns

arrayThe language ID save fields

Remap the specified language ID, and return the ID again - the ID isn't changed.

lang_remap(\ID_TEXT $field_name, mixed $id, string $text, \?object $connection = null, boolean $comcode = false, \?string $pass_id = null, \?MEMBER $source_user = null, boolean $as_admin = false, boolean $backup_string = false) : array
package core

Parameters

$field_name

\ID_TEXT

The field name

$id

mixed

The ID (if multi-lang-content on), or the string itself

$text

string

The text to remap to

$connection

\?object

The database connection to use (null: standard site connection)

$comcode

boolean

Whether it is to be parsed as Comcode

$pass_id

\?string

The special identifier for this lang code on the page it will be displayed on; this is used to provide an explicit binding between languaged elements and greater templated areas (null: none)

$source_user

\?MEMBER

The member that owns the content this is for (null: current member)

$as_admin

boolean

Whether to generate Comcode as arbitrary admin

$backup_string

boolean

Whether to backup the language string before changing it

Returns

arrayThe language ID save fields

Remap the specified Comcode language ID, and return the ID again - the ID isn't changed.

lang_remap_comcode(\ID_TEXT $field_name, mixed $id, string $text, \?object $connection = null, \?string $pass_id = null, \?MEMBER $source_user = null, boolean $as_admin = false) : array
package core

Parameters

$field_name

\ID_TEXT

The field name

$id

mixed

The ID (if multi-lang-content on), or the string itself

$text

string

The text to remap to

$connection

\?object

The database connection to use (null: standard site connection)

$pass_id

\?string

The special identifier for this lang code on the page it will be displayed on; this is used to provide an explicit binding between languaged elements and greater templated areas (null: none)

$source_user

\?MEMBER

The member that owns the content this is for (null: current member)

$as_admin

boolean

Whether to generate Comcode as arbitrary admin

Returns

arrayThe language ID save fields

Take a list of maps, and make one of the values of each array the index of a map to the map

list_to_map(string $map_value, array $list) : array
package core

Parameters

$map_value

string

The key key of our maps that reside in our map

$list

array

The list of maps

Returns

arrayThe collapsed map

Get the parsed contents of a Comcode page.

load_comcode_page(\PATH $string, \ID_TEXT $zone, \ID_TEXT $codename, \?PATH $file_base = null, boolean $being_included = false, \?object $out = null) : \Tempcode
package core

Parameters

$string

\PATH

The relative (to Composr's base directory) path to the page (e.g. pages/comcode/EN/start.txt)

$zone

\ID_TEXT

The zone the page is being loaded from

$codename

\ID_TEXT

The codename of the page

$file_base

\?PATH

The file base to load from (null: standard)

$being_included

boolean

Whether the page is being included from another

$out

\?object

Semi-filled output template (null: definitely not doing output streaming)

Returns

\TempcodeThe page

Get a Comcode page from the cache.

load_comcode_page_from_cache(\ID_TEXT $codename, \ID_TEXT $zone, \ID_TEXT $theme) : array
package core

Parameters

$codename

\ID_TEXT

The codename of the page

$zone

\ID_TEXT

The zone the page is being loaded from

$theme

\ID_TEXT

The theme

Returns

arrayThe page row

Load all config options.

load_config_options() 
package core

Find all restrictions that apply to our page/type.

load_field_restrictions(\?string $this_page = null, \?string $this_type = null) : array
package core

Parameters

$this_page

\?string

The page name scoped for (null: current page)

$this_type

\?string

The page type scoped for (null: current type)

Returns

arrayList of fields, each of which is a map (restriction => attributes)

Get the contents of an HTML page.

load_html_page(\PATH $string, \?PATH $file_base = null, \?object $out = null) : string

HTML isn't great... no dynamicness/reconfigurability at all. We prefer Comcode with [html]HTML goes here[/html] usage

package core

Parameters

$string

\PATH

The relative (to Composrs base directory) path to the HTML page

$file_base

\?PATH

The file base to load from (null: standard)

$out

\?object

Semi-filled output template (null: definitely not doing output streaming)

Returns

stringThe page

Runs the specified mini-module.

load_minimodule_page(\PATH $string, \?object $out = null) : \Tempcode

The module result is returned.

package core

Parameters

$string

\PATH

The relative path to the module file

$out

\?object

Semi-filled output template (null: definitely not doing output streaming)

Returns

\TempcodeThe result of executing the module

Runs the specified module, but also update any stats for the module, and check to see if it needs upgrading or reinstalling.

load_module_page(\PATH $string, \ID_TEXT $codename, \?object $out = null) : \Tempcode

The module result is returned.

package core

Parameters

$string

\PATH

The relative path to the module file

$codename

\ID_TEXT

The page name to load

$out

\?object

Semi-filled output template (null: definitely not doing output streaming)

Returns

\TempcodeThe result of executing the module

Load up hooks needed to detect how to use monikers.

load_moniker_hooks() 
package core

Load up redirect cache.

load_redirect_cache() 
package core

Load up theme image cache.

load_theme_image_cache(object $db, \ID_TEXT $site, \ID_TEXT $true_theme, \LANGUAGE_NAME $true_lang) 
package core

Parameters

$db

object

The database to load from (used for theme images running across multi-site-networks)

$site

\ID_TEXT

The internal name of the database to load from (used for theme images running across multi-site-networks)

$true_theme

\ID_TEXT

Theme0

$true_lang

\LANGUAGE_NAME

Language

For efficiency reasons, load up loads of category permissions.

load_up_all_module_category_permissions(\MEMBER $member, \?ID_TEXT $module = null
package core

Parameters

$member

\MEMBER

The member being checked whether to have the access

$module

\?ID_TEXT

The ID code for the module being checked for category access (null: all categories)

Load stuff that allows user code to work.

load_user_stuff() 
package core

Load all value options.

load_value_options() 
package core

Load up details for the current zone.

load_zone_data() : \ID_TEXT
package core

Returns

\ID_TEXTThe "real" zone name (not actually the zone name, but the zone name wants details to load for).

Filter locale-tainted strings through the locale filter.

locale_filter(string $ret) : string

Let's pretend a user's operating system doesn't fully support they're locale. They have a nice language pack, but whenever the O.S. is asked for dates in the chosen locale, it puts month names in English instead. The locale_filter function is used to cleanup these problems. It does a simple set of string replaces, as defined by the 'locale_subst' language string.

package core

Parameters

$ret

string

Tainted string

Returns

stringFiltered string

Log a hackattack, then displays an error message. It also attempts to send an e-mail to the staff alerting them of the hackattack.

log_hack_attack_and_exit(\ID_TEXT $reason, \SHORT_TEXT $reason_param_a = '', \SHORT_TEXT $reason_param_b = '', boolean $silent = false, boolean $instant_ban = false) : mixed
package core

Parameters

$reason

\ID_TEXT

The reason for the hack attack. This has to be a language string codename

$reason_param_a

\SHORT_TEXT

A parameter for the hack attack language string (this should be based on a unique ID, preferably)

$reason_param_b

\SHORT_TEXT

A more illustrative parameter, which may be anything (e.g. a title)

$silent

boolean

Whether to silently log the hack rather than also exiting

$instant_ban

boolean

Whether a ban should be immediate

Returns

mixedNever returns (i.e. exits)

Log an action

log_it(\ID_TEXT $type, \?SHORT_TEXT $a = null, \?SHORT_TEXT $b = null
package core

Parameters

$type

\ID_TEXT

The type of activity just carried out (a lang string)

$a

\?SHORT_TEXT

The most important parameter of the activity (e.g. id) (null: none)

$b

\?SHORT_TEXT

A secondary (perhaps, human readable) parameter of the activity (e.g. caption) (null: none)

Log statistics for the page view.

log_stats(string $string, integer $pg_time) 
package core

Parameters

$string

string

The string to the page file

$pg_time

integer

The time taken for page loading in milliseconds

Find if a value appears to be some kind of URL (possibly a Composrised Comcode one).

looks_like_url(string $value, boolean $lax = false) : boolean
package core

Parameters

$value

string

The value to check

$lax

boolean

Whether to be a bit lax in the check

Returns

booleanWhether the value appears to be a URL

Get the full name of a language. e.g. 'EN' would become 'English'

lookup_language_full_name(\LANGUAGE_NAME $code) : string
package core

Parameters

$code

\LANGUAGE_NAME

The language

Returns

stringThe full name of the language

Delete a directory of files.

m_deldir(\PATH $a_dir) 

From "User Contributed Notes" at http://it.php.net/manual/en/function.rmdir.php. Thanks flexer at cutephp dot com

package core

Parameters

$a_dir

\PATH

The path to the directory

Attempt to send an e-mail to the specified recipient. The mail will be forwarding to the CC address specified in the options (if there is one, and if not specified not to cc).

mail_wrap(string $subject_line, \LONG_TEXT $message_raw, \?array $to_email = null, \?mixed $to_name = null, \EMAIL $from_email = '', string $from_name = '', integer $priority = 3, \?array $attachments = null, boolean $no_cc = false, \?MEMBER $as = null, boolean $as_admin = false, boolean $in_html = false, boolean $coming_out_of_queue = false, \ID_TEXT $mail_template = 'MAIL', \?boolean $bypass_queue = null, \?array $extra_cc_addresses = null, \?array $extra_bcc_addresses = null, \?TIME $require_recipient_valid_since = null) : \?Tempcode

The mail will be sent in dual HTML/text format, where the text is the unconverted Comcode source: if a member does not read HTML mail, they may wish to fallback to reading that.

package core
range 1 5

Parameters

$subject_line

string

The subject of the mail in plain text

$message_raw

\LONG_TEXT

The message, as Comcode

$to_email

\?array

The destination (recipient) e-mail addresses [array of strings] (null: site staff address)

$to_name

\?mixed

The recipient name. Array or string. (null: site name)

$from_email

\EMAIL

The from address (blank: site staff address)

$from_name

string

The from name (blank: site name)

$priority

integer

The message priority (1=urgent, 3=normal, 5=low)

$attachments

\?array

An list of attachments (each attachment being a map, path=>filename) (null: none)

$no_cc

boolean

Whether to NOT CC to the CC address

$as

\?MEMBER

Convert Comcode->tempcode as this member (a privilege thing: we don't want people being able to use admin rights by default!) (null: guest)

$as_admin

boolean

Replace above with arbitrary admin

$in_html

boolean

HTML-only

$coming_out_of_queue

boolean

Whether to bypass queueing, because this code is running as a part of the queue management tools

$mail_template

\ID_TEXT

The template used to show the email

$bypass_queue

\?boolean

Whether to bypass queueing (null: auto-decide)

$extra_cc_addresses

\?array

Extra CC addresses to use (null: none)

$extra_bcc_addresses

\?array

Extra BCC addresses to use (null: none)

$require_recipient_valid_since

\?TIME

Implement the Require-Recipient-Valid-Since header (null: no restriction)

Returns

\?TempcodeA full page (not complete XHTML) piece of Tempcode to output (null: it worked so no Tempcode message)

Get obfuscate version of 'mailto:' (which'll hopefully fool e-mail scavengers to not pick up these e-mail addresses).

mailto_obfuscated() : string
package core

Returns

stringThe obfuscated 'mailto:' string

Output data to a CSV file.

make_csv(array $data, \ID_TEXT $filename = 'data.csv', boolean $headers = true, boolean $output_and_exit = true, \?PATH $outfile_path = null) : string
package core

Parameters

$data

array

List of maps, each map representing a row

$filename

\ID_TEXT

Filename to output

$headers

boolean

Whether to output CSV headers

$output_and_exit

boolean

Whether to output/exit when we're done instead of return

$outfile_path

\?PATH

File to spool into (null: none)

Returns

stringCSV data (we might not return though, depending on $exit; if $outfile_path is not NULL, this will be blank)

Make some text fractionably editable (i.e. inline editable).

make_fractionable_editable(\ID_TEXT $content_type, mixed $id, mixed $title) : \Tempcode
package core

Parameters

$content_type

\ID_TEXT

Content type

$id

mixed

Content ID

$title

mixed

Content title (either unescaped string, or Compiled Comcode [i.e. Tempcode])

Returns

\TempcodeInline editable HTML to put into output

Set up the locale filter array from the terse language string specifying it.

make_locale_filter() 
package core

Take a PHP map array, and make it look nice.

make_map_nice(array $map) : string
package core

Parameters

$map

array

Map array

Returns

stringPretty version

Make a missing required directory, or exit with an error if we cannot.

make_missing_directory(\PATH $dir) 
package core

Parameters

$dir

\PATH

Path to create

Turn a boring timezone name into the pretty shortened list of ones Microsoft uses and others now use too.

make_nice_timezone_name(string $in) : string
package core

Parameters

$in

string

Boring name

Returns

stringNice name

preg_replace callback to apply sentence case.

make_sentence_case_callback(array $matches) : string
package core

Parameters

$matches

array

Matches

Returns

stringDe-shouted string

Convert a string to Tempcode.

make_string_tempcode(string $string) : \Tempcode
package core

Parameters

$string

string

String

Returns

\TempcodeTempcode

Take a Tempcode object and run some hackerish code to make it XHTML-strict.

make_xhtml_strict(object $global) : object
package core

Parameters

$global

object

Tempcode object

Returns

objectTempcode object (no longer cache safe)

Send an e-mail.

manualproc_mail(string $to, string $subject, string $message, string $additional_headers, string $additional_flags = '') : boolean
package core

Parameters

$to

string

The TO address.

$subject

string

The subject.

$message

string

The message.

$additional_headers

string

Additional headers.

$additional_flags

string

Additional stuff to send to sendmail executable (if appropriate, only works when safe mode is off).

Returns

booleanSuccess status.

Deletes all language codes linked to by the specified table and attribute identifiers, if they exist.

mass_delete_lang(\ID_TEXT $table, array $attrs, \?object $connection) 
package core

Parameters

$table

\ID_TEXT

The table

$attrs

array

The attributes

$connection

\?object

The database connection to use (null: standard site connection)

See if the current URL matches the given Composr match-keys.

match_key_match(mixed $match_keys, boolean $support_post = false, \?array $current_params = null, \?ID_TEXT $current_zone_name = null, \?ID_TEXT $current_page_name = null) : boolean
package core

Parameters

$match_keys

mixed

Match keys (comma-separated list of match-keys, or array of)

$support_post

boolean

Check against POSTed data too

$current_params

\?array

Parameters to check against (null: get from environment GET/POST) - if set, $support_post is ignored)

$current_zone_name

\?ID_TEXT

Current zone name (null: get from environment)

$current_page_name

\?ID_TEXT

Current page name (null: get from environment)

Returns

booleanWhether there is a match

Find whether the current user may see stack dumps.

may_see_stack_dumps() : boolean
package core

Returns

booleanWhether the current user may see stack dumps

Given a particular bit of feedback content, check if the user may access it.

may_view_content_behind(\MEMBER $member_id, \ID_TEXT $content_type, \ID_TEXT $content_id, \ID_TEXT $type_has = 'content_type') : boolean
package core

Parameters

$member_id

\MEMBER

User to check

$content_type

\ID_TEXT

Content type

$content_id

\ID_TEXT

Content ID

$type_has

\ID_TEXT

Content type type

Returns

booleanWhether there is permission

Exit with debug data, only for a specific IP address.

me_debug(\IP $ip, mixed $data) 
package core

Parameters

$ip

\IP

IP address of tester

$data

mixed

Data to display

Find if a member is blocked by a member.

member_blocked(\MEMBER $member_id, \?MEMBER $member_blocker = null) : boolean
package core

Parameters

$member_id

\MEMBER

The member being checked

$member_blocker

\?MEMBER

The member who may be blocking (null: current member)

Returns

booleanWhether the member is blocked

Find if a member is online.

member_is_online(\MEMBER $member_id) : boolean
package core

Parameters

$member_id

\MEMBER

The member to check

Returns

booleanWhether they are online

Update the member tracker for the currently viewing user.

member_tracking_update(\ID_TEXT $page, \ID_TEXT $type, \ID_TEXT $id) 
package core

Parameters

$page

\ID_TEXT

The page

$type

\ID_TEXT

The type

$id

\ID_TEXT

The ID

Raise the PHP memory limit to cater for a requested large result set.

memory_limit_for_max_param(\ID_TEXT $max_param) 
package core

Parameters

$max_param

\ID_TEXT

The max parameter name

Record the memory usage at this point.

memory_trace_point(\?string $name = null
package core

Parameters

$name

\?string

The name of the memory point (null: use a simple counter)

Log excessive memory usage.

memory_tracking() 
package core

Do a user sort, preserving order where reordering not needed. Based on a PHP manual comment at http://php.net/manual/en/function.usort.php

merge_sort(array $array, mixed $cmp_function = 'strcmp'
package core

Parameters

$array

array

Sort array

$cmp_function

mixed

Comparison function

Give an error about a missing template parameter

missing_template_parameter(\ID_TEXT $origin) : string
package core

Parameters

$origin

\ID_TEXT

Where this parameter is referenced, in a slash-combined reference form

Returns

stringAlways ""

Assign this to explicitly declare that a variable may be of mixed type, and initialise to NULL.

mixed() : \?mixed
package core

Returns

\?mixedOf mixed type (null: default)

Check to see if a module is installed.

module_installed(\ID_TEXT $module) : boolean
package core

Parameters

$module

\ID_TEXT

The module name

Returns

booleanWhether it is

Use with register_shutdown_function to log slow URLs.

monitor_slow_urls() 
package core

Find whether to run in multi-lang mode.

multi_lang() : boolean
package core

Returns

booleanWhether to run in multi-lang mode.

Find whether to run in multi-lang mode for content translations.

multi_lang_content() : boolean
package core

Returns

booleanWhether to run in multi-lang mode for content translations.

Get special SQL from POSTed parameters for a catalogue search field for a multi-input field that is to be exact-matched.

nl_delim_match_sql(array $field, integer $i, \ID_TEXT $type = 'short', \?string $param = null) : \?array
package core
set short long

Parameters

$field

array

The field details

$i

integer

We're processing for the ith row

$type

\ID_TEXT

Table type

$param

\?string

Search term (null: lookup from environment)

Returns

\?arrayTuple of SQL details (array: extra trans fields to search, array: extra plain fields to search, string: an extra table segment for a join, string: the name of the field to use as a title, if this is the title, extra WHERE clause stuff) (null: nothing special)

Normalise a provided IP address

normalise_ip_address(\IP $ip, \?integer $amount = null) : \IP
package core

Parameters

$ip

\IP

The IP address to normalise

$amount

\?integer

Amount to mask out (null: do not)

Returns

\IPThe normalised IP address

Add a row to our sitemap cache.

notify_sitemap_node_add(\SHORT_TEXT $page_link, \?TIME $add_date, \?TIME $edit_date, float $priority, \ID_TEXT $refreshfreq, boolean $guest_access) 
package core
set always hourly daily weekly monthly yearly never

Parameters

$page_link

\SHORT_TEXT

The page-link

$add_date

\?TIME

The add time (null: unknown)

$edit_date

\?TIME

The edit time (null: same as add time)

$priority

float

The sitemap priority, a SITEMAPIMPORTANCE* constant

$refreshfreq

\ID_TEXT

The refresh frequency

$guest_access

boolean

Whether guests may access this resource in terms of category permissions not zone/page permissions (if not set to 1 then it will not end up in an XML sitemap, but we'll keep tabs of it for other possible uses)

Mark a row from our sitemap cache as for deletion.

notify_sitemap_node_delete(\SHORT_TEXT $page_link) 

It won't be immediately deleted, as we use this as a signal that the XML sitemap will need updating too. Updates are done in batch, via CRON.

package core

Parameters

$page_link

\SHORT_TEXT

The page-link

Edit a row in our sitemap cache.

notify_sitemap_node_edit(\SHORT_TEXT $page_link, boolean $guest_access) 
package core

Parameters

$page_link

\SHORT_TEXT

The page-link

$guest_access

boolean

Whether guests may access this resource in terms of category permissions not zone/page permissions (if not set to 1 then it will not end up in an XML sitemap, but we'll keep tabs of it for other possible uses)

Obfuscate the given e-mail address.

obfuscate_email_address(string $email) : string

This function may want to be modified on a per-site basis, to stop spammers triggering onto Composr's default method (possible some already do, although I think it unlikely they would go to this much effort/computation unless it was more widespread to do this).

package core

Parameters

$email

string

The e-mail address to obfuscate

Returns

stringThe obfuscated version

Obfuscate the given text using HTML entity encoding.

obfuscate_entities(string $val) : string
package core

Parameters

$val

string

The text to obfuscate

Returns

stringThe obfuscated version

Make an object of the given class

object_factory(string $class, boolean $failure_ok = false) : \?object
package core

Parameters

$class

string

The class name

$failure_ok

boolean

Whether to return NULL if there is no such class

Returns

\?objectThe object (null: no such class)

Server opensearch requests.

opensearch_script() 
package core

Optimise for memory and execution time. This is typically used before something is cached.

optimise_tempcode(object $ob) 
package core

Parameters

$ob

object

Optimise a Tempcode object.

Get a string (natural for Tempcode's stream-based processing-model) representation of a bound Tempcode variable

otp(mixed $var, \ID_TEXT $origin = '') : string
package core

Parameters

$var

mixed

Variable (or NULL if not set)

$origin

\ID_TEXT

Where this parameter is referenced, in a compressed reference form

Returns

stringValue

Render that the page wasn't found. Show alternate likely candidates based on misspellings.

page_not_found(\ID_TEXT $codename, \ID_TEXT $zone) : \Tempcode
package core

Parameters

$codename

\ID_TEXT

The codename of the page to load

$zone

\ID_TEXT

The zone the page is being loaded in

Returns

\TempcodeMessage

Get the Tempcode for a paragraph. This function should only be used with escaped text strings that need to be put into a paragraph, not with sections of HTML. Remember, paragraphs are literally that, and should only be used with templates that don't assume that they are going to put the given parameters into paragraphs themselves.

paragraph(mixed $text, string $guid = '', \?string $class = null) : \Tempcode
package core

Parameters

$text

mixed

The text to put into the paragraph (string or Tempcode)

$guid

string

GUID for call

$class

\?string

CSS classname (null: none)

Returns

\TempcodeThe generated paragraph

Parse some string based Filtercode search filters into the expected array structure.

parse_filtercode(string $filter) : array
package core

Parameters

$filter

string

String-based search filter

Returns

arrayParsed structure

Parse raw HTTP request data.

parse_raw_http_request() : \?array
package core

Returns

\?arrayAssociative array of request data (null: could not rescue)

get_translated_tempcode was asked for a lang entry that had not been parsed into Tempcode yet.

parse_translated_text(\ID_TEXT $table, array $row, \ID_TEXT $field_name, \?object $connection, \?LANGUAGE_NAME $lang, boolean $force, boolean $as_admin) : \?Tempcode
package core

Parameters

$table

\ID_TEXT

The table name

$row

array

The database row

$field_name

\ID_TEXT

The field name

$connection

\?object

The database connection to use (null: standard site connection)

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

$force

boolean

Whether to force it to the specified language

$as_admin

boolean

Whether to force as_admin, even if the lang string isn't stored against an admin (designed for Comcode page caching)

Returns

\?TempcodeThe parsed Comcode (null: the text couldn't be looked up)

Hash the password using the specified algorithm

password_hash(string $password, integer $algo, array $options) : \~string
package core

Parameters

$password

string

The password to hash

$algo

integer

The algorithm to use (Defined by PASSWORD_* constants)

$options

array

The options for the algorithm to use

Returns

\~stringThe hashed password (false: error)

Verify a password against a hash using a timing attack resistant approach

password_verify(string $password, string $hash) : boolean
package core

Parameters

$password

string

The password to verify

$hash

string

The hash to verify against

Returns

booleanIf the password matches the hash

Check if a privilege exists.

permission_exists(\ID_TEXT $name) : boolean
package core

Parameters

$name

\ID_TEXT

The name of the option

Returns

booleanWhether it exists

Delete data from the persistent cache.

persistent_cache_delete(mixed $key, boolean $substring = false
package core

Parameters

$key

mixed

Key name

$substring

boolean

Whether we are deleting via substring

Get data from the persistent cache.

persistent_cache_get(mixed $key, \?TIME $min_cache_date = null) : \?mixed
package core

Parameters

$key

mixed

Key

$min_cache_date

\?TIME

Minimum timestamp that entries from the cache may hold (null: don't care)

Returns

\?mixedThe data (null: not found / NULL entry)

Put data into the persistent cache.

persistent_cache_set(mixed $key, mixed $data, boolean $server_wide = false, \?integer $expire_secs = null
package core

Parameters

$key

mixed

Key

$data

mixed

The data

$server_wide

boolean

Whether it is server-wide data

$expire_secs

\?integer

The expiration time in seconds. (null: Default expiry in 60 minutes, or never if it is server-wide).

Escape a string to fit within PHP double quotes.

php_addslashes(string $in) : string
package core

Parameters

$in

string

String in

Returns

stringResultant string

Escape a string to fit within PHP double quotes TWICE. Needed sometimes when generating code. This function exists for performance reasons.

php_addslashes_twice(string $in) : string
package core

Parameters

$in

string

String in

Returns

stringResultant string

Find whether a particular PHP function is blocked.

php_function_allowed(string $function) : boolean
package core

Parameters

$function

string

Function name.

Returns

booleanWhether it is.

Get the number of bytes for a PHP config option. Code taken from the PHP manual.

php_return_bytes(string $val) : integer
package core

Parameters

$val

string

PHP config option value.

Returns

integerNumber of bytes.

Ping search engines with an updated sitemap.

ping_sitemap_xml(\URLPATH $url) : string
package core

Parameters

$url

\URLPATH

Sitemap URL

Returns

stringHTTP result output

Try to further compress a PNG file, via palette tricks and maximum gzip compression.

png_compress(\PATH $path, boolean $lossy = false
package core

Parameters

$path

\PATH

File path.

$lossy

boolean

Whether to do a lossy convert.

This function is the integeric partner of post_param_string, as it returns the value as an integer.

post_param_integer(\ID_TEXT $name, \?mixed $default = false) : \?integer
package core

Parameters

$name

\ID_TEXT

The name of the parameter to get

$default

\?mixed

The default value to give the parameter if the parameter value is not defined or the empty string (null: allow missing parameter) (false: give error on missing parameter)

Returns

\?integerThe parameter value (null: not set, and NULL given as default)

An upload has been passed through by POST, either as a file (a new upload), a url, or as a filedump reference.

post_param_multi_source_upload(\ID_TEXT $name, \?PATH $upload_to, boolean $required = true, boolean $is_edit = false, \?string $filename = null, \?string $thumb_url = null, integer $upload_type = 15, boolean $copy_to_server = false) : \?URLPATH

For images use post_param_image instead. Used with form_input_upload_multi_source. Get the file URL from the POST data.

package core

Parameters

$name

\ID_TEXT

Form field prefix (input type suffixes will be added automatically)

$upload_to

\?PATH

Where to upload to (null: the correct place for $theme_image_type)

$required

boolean

Whether an image is required

$is_edit

boolean

Whether this is an edit operation

$filename

\?string

Pass the filename back by reference (null: do not pass)

$thumb_url

\?string

Pass the thumbnail back by reference (null: do not pass & do not collect a thumbnail)

$upload_type

integer

A CMSUPLOAD* constant

$copy_to_server

boolean

Whether to copy a URL (if a URL) to the server, and return a local reference

Returns

\?URLPATHThe URL (either to an independent upload, or the theme image, or a filedump URL) (null: leave alone, when doing an edit operation)

Get the value of the specified POST parameter (i.e. like $_POST[$name]) if it is passed, or the default otherwise.

post_param_string(\ID_TEXT $name, \?mixed $default = false, boolean $html = false, boolean $conv_from_wysiwyg = true) : \?string

Implements additional security over the direct PHP access mechanism which should not be used.

package core

Parameters

$name

\ID_TEXT

The name of the parameter to get

$default

\?mixed

The default value to give the parameter if the parameter value is not defined (null: allow missing parameter) (false: give error on missing parameter)

$html

boolean

Whether we are cleaning for HTML rather than Comcode/plain-text

$conv_from_wysiwyg

boolean

Whether to convert WYSIWYG contents to Comcode automatically

Returns

\?stringThe parameter value (null: missing)

Pre-load used blocks in bulk.

preload_block_internal_caching() 
package core

Get ready for outputting an AJAX response.

prepare_for_known_ajax_response() 
package core

Prevent double submission, by reference to recent matching admin log entries by the current member.

prevent_double_submit(\ID_TEXT $type, \?SHORT_TEXT $a = null, \?SHORT_TEXT $b = null
package core

Parameters

$type

\ID_TEXT

The type of activity just carried out (a lang string)

$a

\?SHORT_TEXT

The most important parameter of the activity (e.g. id) (null: none / cannot match against)

$b

\?SHORT_TEXT

A secondary (perhaps, human readable) parameter of the activity (e.g. caption) (null: none / cannot match against)

Process URL monikers, changing 'id' GET param to be correct.

process_url_monikers(\ID_TEXT $page, boolean $redirect_if_non_canonical = true
package core

Parameters

$page

\ID_TEXT

The page name to do it for

$redirect_if_non_canonical

boolean

Do a redirect if we're not on the canonical URL

Get a decent randomised salt.

produce_salt() : \ID_TEXT
package core

Returns

\ID_TEXTThe salt

Propagate Filtercode through links.

propagate_filtercode(\ID_TEXT $prefix = '') : array
package core

Parameters

$prefix

\ID_TEXT

Prefix for main filter environment variable

Returns

arrayExtra URL mappings

Stop some text being escapable by the Tempcode layer.

protect_from_escaping(mixed $in) : \Tempcode
package core

Parameters

$in

mixed

Text

Returns

\TempcodeText that can't be escaped

Push the output state on the stack and create a fresh one.

push_output_state(boolean $just_tempcode = false, boolean $true_blank = false
package core
sets_output_state

Parameters

$just_tempcode

boolean

Whether to only restore the Tempcode execution part of the state.

$true_blank

boolean

Whether to go for a completely blank state (no defaults!), not just a default fresh state.

Get the Tempcode for a standard box (CSS driven), with the specified content entered. Please rarely use this function; it is not good to assume people want anythings in one of these boxes.

put_in_standard_box(\Tempcode $content, mixed $title = '', \ID_TEXT $type = 'default', string $width = '', string $options = '', string $meta = '', string $links = '', string $top_links = '') : \Tempcode

.. use templates instead

package core

Parameters

$content

\Tempcode

The content being put inside the box

$title

mixed

The title of the standard box, string or Tempcode (blank: titleless standard box)

$type

\ID_TEXT

The type of the box. Refers to a template (STANDARDBOX_type)

$width

string

The CSS width

$options

string

'|' separated list of options (meaning dependant upon templates interpretation)

$meta

string

'|' separated list of meta information (key|value|key|value|...)

$links

string

'|' separated list of link information (linkhtml|...)

$top_links

string

Link to be added to the header of the box

Returns

\TempcodeThe contents, put inside a standard box, according to the other parameters

Put a result into the cache.

put_into_cache(\MINIID_TEXT $codename, integer $ttl, \LONG_TEXT $cache_identifier, \?BINARY $staff_status, \?MEMBER $member, \SHORT_TEXT $groups, \?BINARY $is_bot, \MINIID_TEXT $timezone, mixed $cache, \?array $_langs_required = null, \?array $_javascripts_required = null, \?array $_csss_required = null, boolean $tempcode = false, \?ID_TEXT $theme = null, \?LANGUAGE_NAME $lang = null
package core

Parameters

$codename

\MINIID_TEXT

The codename to check for caching

$ttl

integer

The TTL of what is being cached in minutes

$cache_identifier

\LONG_TEXT

The requisite situational information (a serialized map) [-> further restraints when reading]

$staff_status

\?BINARY

Staff status to limit to (null: Not limiting by this)

$member

\?MEMBER

Member to limit to (null: Not limiting by this)

$groups

\SHORT_TEXT

Sorted permissive usergroup list to limit to (blank: Not limiting by this)

$is_bot

\?BINARY

Bot status to limit to (null: Not limiting by this)

$timezone

\MINIID_TEXT

Timezone to limit to (blank: Not limiting by this)

$cache

mixed

The result we are caching

$_langs_required

\?array

A list of the language files that need loading to use Tempcode embedded in the cache (null: none required)

$_javascripts_required

\?array

A list of the javascript files that need loading to use Tempcode embedded in the cache (null: none required)

$_csss_required

\?array

A list of the css files that need loading to use Tempcode embedded in the cache (null: none required)

$tempcode

boolean

Whether we are caching Tempcode (needs special care)

$theme

\?ID_TEXT

The theme this is being cached for (null: current theme)

$lang

\?LANGUAGE_NAME

The language this is being cached for (null: current language)

Prepare a value for display in a stack trace.

put_value_in_stack_trace(mixed $value) : string
package core

Parameters

$value

mixed

Complex value

Returns

stringString version

Take a URL and base-URL, and fully qualify the URL according to it.

qualify_url(\URLPATH $url, \URLPATH $url_base) : \URLPATH
package core

Parameters

$url

\URLPATH

The URL to fully qualified

$url_base

\URLPATH

The base-URL

Returns

\URLPATHFully qualified URL

Do a hashing, with support for our "ratcheting up" algorithm (i.e. lets the admin increase the complexity over the time, as CPU speeds get faster).

ratchet_hash(\SHORT_TEXT $password, \SHORT_TEXT $salt, integer $legacy_style = 0) : \SHORT_TEXT
package core

Parameters

$password

\SHORT_TEXT

The password in plain text

$salt

\SHORT_TEXT

The salt

$legacy_style

integer

Legacy hashing style to fallback to

Returns

\SHORT_TEXTThe salted&hashed password

Verify a password is correct by comparison of the hashed version.

ratchet_hash_verify(\SHORT_TEXT $password, \SHORT_TEXT $salt, \SHORT_TEXT $pass_hash_salted, integer $legacy_style = 0) : boolean
package core

Parameters

$password

\SHORT_TEXT

The password in plain text

$salt

\SHORT_TEXT

The salt

$pass_hash_salted

\SHORT_TEXT

The prior salted&hashed password, which will also include the algorithm/ratcheting level (unless it's old style, in which case we use non-ratcheted md5)

$legacy_style

integer

Legacy hashing style to fallback to

Returns

booleanWhether the password if verified

Do an RBL lookup (low level, uninterpreted).

rbl_resolve(\IP $ip, \ID_TEXT $rbl_domain, boolean $page_level) : \?array
package core

Parameters

$ip

\IP

The IP address to lookup

$rbl_domain

\ID_TEXT

The RBL domain

$page_level

boolean

Whether this is a page level check (i.e. we won't consider blocks or approval, just ban setting)

Returns

\?arrayReturn result (null: error)

Read an Filtercode parameter value from GET/POST.

read_filtercode_parameter_from_env(\ID_TEXT $field_name, \?ID_TEXT $field_type = null) : string
package core

Parameters

$field_name

\ID_TEXT

The field name

$field_type

\?ID_TEXT

The field type (null: work out what is there to read automatically)

Returns

stringThe parameter value

Read a text file, using the _custom system

read_text_file(string $codename, \?LANGUAGE_NAME $lang = null, boolean $missing_blank = false) : string
package core

Parameters

$codename

string

The file name (without .txt)

$lang

\?LANGUAGE_NAME

The language to load from (null: none) (blank: search)

$missing_blank

boolean

Whether to tolerate missing files

Returns

stringThe file contents

Write out a Sitemap XML index.

rebuild_sitemap_index() 
package core

Write out a Sitemap XML set.

rebuild_sitemap_set(integer $set_number, \TIME $last_time) 
package core

Parameters

$set_number

integer

Set number

$last_time

\TIME

Last sitemap generation time

Redirect the user - transparently, storing a message that will be shown on their destination page.

redirect_screen(\Tempcode $title, mixed $url, \?mixed $text = null, boolean $intermediary_hop = false, \ID_TEXT $msg_type = 'inform') : \Tempcode
package core
set warn inform fatal

Parameters

$title

\Tempcode

Title to display on redirect page

$url

mixed

Destination URL (may be Tempcode)

$text

\?mixed

Message to show (may be Tempcode) (null: standard redirection message)

$intermediary_hop

boolean

For intermediary hops, don't mark so as to read status messages - save them up for the next hop (which will not be intermediary)

$msg_type

\ID_TEXT

Code of message type to show

Returns

\TempcodeRedirection message (likely to not actually be seen due to instant redirection)

Reinstall a block if it has become corrupted for any reason.

reinstall_block(\ID_TEXT $block) : boolean

Again, you should not need to use this function.

package core

Parameters

$block

\ID_TEXT

The name of the block to reinstall

Returns

booleanWhether installation was required

Reinstall the specified module.

reinstall_module(\ID_TEXT $zone, \ID_TEXT $module) : boolean
package core

Parameters

$zone

\ID_TEXT

The zone name

$module

\ID_TEXT

The module name

Returns

booleanWhether a module installer had to be run

Relay an error message, if appropriate, to e-mail listeners (sometimes ocProducts, and site staff).

relay_error_notification(string $text, boolean $ocproducts = true, \ID_TEXT $notification_type = 'error_occurred'
package core

Parameters

$text

string

A error message (in HTML)

$ocproducts

boolean

Also send to ocProducts

$notification_type

\ID_TEXT

The notification type

Reload language fields from the database.

reload_lang_fields(boolean $full = false
package core

Parameters

$full

boolean

Whether we need to know about non-Comcode language fields

Remove some code from a function in the given code snippet.

remove_code(string $code, string $function, string $command, integer $instance_of_command = 1) : boolean
package core

Parameters

$code

string

The code.

$function

string

Name of the function.

$command

string

The command we're searching to insert by.

$instance_of_command

integer

We remove the nth instance of this command.

Returns

booleanSuccess status.

Remove any duplication inside the list of rows (each row being a map). Duplication is defined by rows with correspinding IDs.

remove_duplicate_rows(array $rows, string $id_field = 'id') : array
package core

Parameters

$rows

array

The rows to remove duplication of

$id_field

string

The ID field

Returns

arrayThe filtered rows

Remove an IP-ban.

remove_ip_ban(\IP $ip) 
package core

Parameters

$ip

\IP

The IP address to unban

Remove the magic encryption marker from some data. This should be used if the data is to be displayed or presented for editing, but not if it's to be put in the database.

remove_magic_encryption_marker(string $data) : string

If the data does not have a magic encryption marker, the original string will be returned.

package core

Parameters

$data

string

Data

Returns

stringData, without the magic marker

Map spaces to %20 and put http:// in front of URLs starting www.

remove_url_mistakes(\URLPATH $url) : \URLPATH
package core

Parameters

$url

\URLPATH

The URL to fix

Returns

\URLPATHThe fixed result

Rename a config option.

rename_config_option(\ID_TEXT $old, \ID_TEXT $new) 
package core

Parameters

$old

\ID_TEXT

The old name

$new

\ID_TEXT

The new name

Rename a privilege.

rename_privilege(\ID_TEXT $old, \ID_TEXT $new) 
package core

Parameters

$old

\ID_TEXT

The old name

$new

\ID_TEXT

The new name

Render a Comcode page box.

render_comcode_page_box(array $row, boolean $give_context = true, boolean $include_breadcrumbs = true, \?ID_TEXT $root = null, \ID_TEXT $guid = '') : \Tempcode
package core

Parameters

$row

array

Row to render

$give_context

boolean

Whether to include context (i.e. say WHAT this is, not just show the actual content)

$include_breadcrumbs

boolean

Whether to include breadcrumbs (if there are any)

$root

\?ID_TEXT

Virtual root to use (null: none)

$guid

\ID_TEXT

Overridden GUID to send to templates (blank: none)

Returns

\TempcodeRendered box

Take a URL and process it to make a hard include. We'll get the HTML and we'll also load up some global stuff for 'do_header' to use.

reprocess_url(\URLPATH $url, \URLPATH $operation_base_url) : string
package core

Parameters

$url

\URLPATH

The URL that we're operating on.

$operation_base_url

\URLPATH

We open up linked URLs under this recursively.

Returns

stringThe cleaned up contents at the URL, set up for the recursive integrator usage.

Take the specified parameters, and try to find the corresponding page, then execute a function to load the page (load_html_page/load_comcode_page).

request_page(\ID_TEXT $codename, boolean $required, \?ID_TEXT $zone = null, \?ID_TEXT $page_type = null, boolean $being_included = false, boolean $no_redirect_check = false, \?object $out = null) : \?Tempcode
package core

Parameters

$codename

\ID_TEXT

The codename of the page to load

$required

boolean

Whether it is required for this page to exist (shows an error if it doesn't) -- otherwise, it will just return NULL

$zone

\?ID_TEXT

The zone the page is being loaded in (null: as shown by access URL)

$page_type

\?ID_TEXT

The type of page - for if you know it (null: don't know it)

$being_included

boolean

Whether the page is being included from another

$no_redirect_check

boolean

Whether to not check for redirects (normally you would)

$out

\?object

Semi-filled output template (null: definitely not doing output streaming)

Returns

\?TempcodeThe page (null: no page)

Request that CRON loads up a block's caching in the background.

request_via_cron(\ID_TEXT $codename, \?array $map, integer $special_cache_flags, boolean $tempcode) 
package core

Parameters

$codename

\ID_TEXT

The codename of the block

$map

\?array

Parameters to call up block with if we have to defer caching (null: none)

$special_cache_flags

integer

Flags representing how we should cache

$tempcode

boolean

Whether we are caching Tempcode (needs special care)

Include all the language files for use in the script.

require_all_lang(\?LANGUAGE_NAME $lang = null, boolean $only_if_for_lang = false

NOTE: This may reduce performance, so you should only use it if you really have to.

package core

Parameters

$lang

\?LANGUAGE_NAME

The language to include files from (null: use current users language).

$only_if_for_lang

boolean

Only load it up if it is specifically defined for our language.

Require all the open language files. This doesn't hurt performance a lot.

require_all_open_lang_files(\?LANGUAGE_NAME $lang = null
package core

Parameters

$lang

\?LANGUAGE_NAME

The language to require open files from (null: uses the current language)

This function is a very important one when coding. It allows you to include a source code file (from root/sources/ or root/sources_custom/) through the proper channels.

require_code(string $codename, boolean $light_exit = false

You should remember this function, and not substitute anything else for it, as that will likely make your code unstable. It is key to source code modularity in Composr.

package core

Parameters

$codename

string

The codename for the source module to load (or a full relative path, ending with .php; if custom checking is needed, this must be the custom version)

$light_exit

boolean

Whether to cleanly fail when a source file is missing

Require code, but without looking for sources_custom overrides

require_code_no_override(string $codename) 
package core

Parameters

$codename

string

The codename for the source module to load

Make sure that the given CSS file is loaded up.

require_css(\ID_TEXT $css) 
package core
sets_output_state

Parameters

$css

\ID_TEXT

The CSS file required

Make sure that the given javascript file is loaded up.

require_javascript(\ID_TEXT $javascript) 
package core
sets_output_state

Parameters

$javascript

\ID_TEXT

The javascript file required

Includes a language file for use in the script.

require_lang(\ID_TEXT $codename, \?LANGUAGE_NAME $lang = null, \?string $type = null, boolean $ignore_errors = false

If $type is not null, then this specifies whether to use 'lang_custom' or 'custom' (otherwise, normal priorities occur).

package core
set lang_custom custom

Parameters

$codename

\ID_TEXT

The language file name

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

$type

\?string

The language type (lang_custom, or custom) (null: normal priorities are used)

$ignore_errors

boolean

Whether to just return if there was a loading error

Load up a language file, compiling it (it's not cached yet).

require_lang_compile(\ID_TEXT $codename, \?LANGUAGE_NAME $lang, \?string $type, \PATH $cache_path, boolean $ignore_errors = false) : boolean
package core
set lang_custom custom

Parameters

$codename

\ID_TEXT

The language file name

$lang

\?LANGUAGE_NAME

The language (null: uses the current language)

$type

\?string

The language type (lang_custom, or custom) (null: normal priorities are used)

$cache_path

\PATH

Where we are caching too

$ignore_errors

boolean

Whether to just return if there was a loading error

Returns

booleanWhether we FAILED to load

Detect if the POST request was shortened due to a limitation.

rescue_shortened_post_request() 

If we're staff, try and fix it. If we're not staff, warn about it (as fixing it would subvert the reason for the restriction).

package core

Restore the last output state on the stack, or a fresh one if none was pushed.

restore_output_state(boolean $just_tempcode = false, boolean $merge_current = false, \?array $keep = null
package core
sets_output_state

Parameters

$just_tempcode

boolean

Whether to only restore the Tempcode execution part of the state.

$merge_current

boolean

Whether to merge the current output state in.

$keep

\?array

Settings to keep / merge if possible (null: none).

Backdoor handler. Can only be activated by those with FTP write-access.

restricted_manually_enabled_backdoor() : \MEMBER
package core

Returns

\MEMBERThe member to simulate

Add Composr's strictness, after finishing with third-party code. To be run optionally at some point after destrictify().

restrictify() 
package core

Find details of a position in the Sitemap (shortcut into the object structure).

retrieve_sitemap_node(\ID_TEXT $page_link = '', \?mixed $callback = null, \?array $valid_node_types = null, \?integer $child_cutoff = null, \?integer $max_recurse_depth = null, integer $options = 0, \ID_TEXT $zone = '_SEARCH', integer $meta_gather = 0) : \?array
package core

Parameters

$page_link

\ID_TEXT

The page-link we are finding (blank: root).

$callback

\?mixed

Callback function to send discovered page-links to (null: return).

$valid_node_types

\?array

List of node types we will return/recurse-through (null: no limit)

$child_cutoff

\?integer

Maximum number of children before we cut off all children (null: no limit).

$max_recurse_depth

\?integer

How deep to go from the Sitemap root (null: no limit).

$options

integer

A bitmask of SITEMAPGEN* options.

$zone

\ID_TEXT

The zone we will consider ourselves to be operating in (needed due to transparent redirects feature)

$meta_gather

integer

A bitmask of SITEMAPGATHER* constants, of extra data to include.

Returns

\?arrayNode structure (null: working via callback / error).

Find whether Composr is running on a local network, rather than a live-site.

running_locally() : boolean
package core

Returns

booleanIf it is running locally

Find whether a certain script is being run to get here.

running_script(string $is_this_running) : boolean
package core

Parameters

$is_this_running

string

Script filename (canonically we want NO .php file type suffix)

Returns

booleanWhether the script is running

Sets the value of a configuration option, if the PHP environment allows it.

safe_ini_set(string $var, string $value) : \~string
package core

Parameters

$var

string

Config option.

$value

string

New value of option.

Returns

\~stringOld value of option (false: error).

Save a Comcode page.

save_comcode_page(\ID_TEXT $zone, \ID_TEXT $new_file, \LANGUAGE_NAME $lang, \ID_TEXT $text, \BINARY $validated, \?ID_TEXT $parent_page = null, integer $order = 0, \?TIME $add_time = null, \?TIME $edit_time = null, \BINARY $show_as_edit = 0, \?MEMBER $submitter = null, \?ID_TEXT $file = null, \SHORT_TEXT $meta_keywords = '', \LONG_TEXT $meta_description = '') : \PATH
package core

Parameters

$zone

\ID_TEXT

The zone

$new_file

\ID_TEXT

The page

$lang

\LANGUAGE_NAME

The language

$text

\ID_TEXT

The page text

$validated

\BINARY

The validated status

$parent_page

\?ID_TEXT

The page parent (null: none)

$order

integer

The page order

$add_time

\?TIME

Add time (null: now)

$edit_time

\?TIME

Edit time (null: not edited)

$show_as_edit

\BINARY

Whether to show as edited

$submitter

\?MEMBER

The submitter (null: current member)

$file

\?ID_TEXT

The old page name (null: not being renamed)

$meta_keywords

\SHORT_TEXT

Meta keywords for this resource (blank: implicit)

$meta_description

\LONG_TEXT

Meta description for this resource (blank: implicit)

Returns

\PATHThe save path

Do any static cache saving that we want to do.

save_static_caching(mixed $out, string $mime_type = 'text/html'
package core

Parameters

$out

mixed

Output to cache (Tempcode or string)

$mime_type

string

Mime type to use

Save a zone base URL.

save_zone_base_url(\ID_TEXT $zone, string $base_url) 
package core

Parameters

$zone

\ID_TEXT

The zone

$base_url

string

The base URL (blank: natural)

Check serialized data for objects, as a security measure.

secure_serialized_data(string $data, \?mixed $safe_replacement = null
package core

Parameters

$data

string

&$data Serialized data

$safe_replacement

\?mixed

What to substitute if objects are contained (null: substitute null)

Turn an Selectcode (a filter specifying which records to match) into a list of ID numbers.

selectcode_to_idlist_using_callback(string $filter, string $ids_and_parents_callback, \?string $parent_spec__table_name = null, \?string $parent_spec__parent_name = null, \?string $parent_field_name = null, \?string $parent_spec__field_name = null, boolean $numeric_record_set_ids = true, boolean $numeric_category_set_ids = true, \?object $db = null) : array
package core

Parameters

$filter

string

The filter

$ids_and_parents_callback

string

A call_user_func_array specifier to a function that will give a map between record-set IDs and record-set parent-category-IDs. We pass a call_user_func_array specifier because we don't want to have to generate it unless we need to (if we need to do 'avoiding' matches or 'subtree' matches)

$parent_spec__table_name

\?string

The database's table that contains parent/child relationships in the record-set's category-set (the category-set is equal to the record-set if we're matching categories, but not if we're matching entries) (null: don't support subtree [*-style] searches)

$parent_spec__parent_name

\?string

The database's field name for the category-set's parent-category-ID (null: don't support subtree [*-style] searches beyond the tree base)

$parent_field_name

\?string

The database's field name for the record-set's container-category specifier (null: don't support subtree [*-style] searches)

$parent_spec__field_name

\?string

The database's field name for the category-set's category-ID (null: don't support subtree [*-style] searches beyond the tree base)

$numeric_record_set_ids

boolean

Whether the record-set IDs are numeric

$numeric_category_set_ids

boolean

Whether the category-set IDs are numeric

$db

\?object

Database connection to use (null: website)

Returns

arrayA list of ID numbers

Turn an Selectcode (a filter specifying which records to match) into a list of ID numbers, relying on the database to extract the record-set.

selectcode_to_idlist_using_db(string $filter, string $field_name, string $table_name, \?string $parent_spec__table_name = null, \?string $parent_spec__parent_name = null, \?string $parent_field_name = null, \?string $parent_spec__field_name = null, boolean $numeric_record_set_ids = true, boolean $numeric_category_set_ids = true, \?object $db = null) : array
package core

Parameters

$filter

string

The filter

$field_name

string

The database's ID field for the record-set we're matching

$table_name

string

The database's table for the record-set we're matching

$parent_spec__table_name

\?string

The database's table that contains parent/child relationships in the record-set's category-set (the category-set is equal to the record-set if we're matching categories, but not if we're matching entries) (null: don't support subtree [*-style] searches)

$parent_spec__parent_name

\?string

The database's field name for the category-set's parent-category-ID (null: don't support subtree [*-style] searches beyond the tree base)

$parent_field_name

\?string

The database's field name for the record-set's container-category specifier (null: don't support subtree [*-style] searches)

$parent_spec__field_name

\?string

The database's field name for the category-set's category-ID (null: don't support subtree [*-style] searches beyond the tree base)

$numeric_record_set_ids

boolean

Whether the record-set IDs are numeric

$numeric_category_set_ids

boolean

Whether the category-set IDs are numeric

$db

\?object

Database connection to use (null: website)

Returns

arrayA list of ID numbers

Turn an Selectcode (a filter specifying which records to match) into a list of ID numbers, using a prebuilt memory representation of the record-set.

selectcode_to_idlist_using_memory(string $filter, array $ids_and_parents, \?string $parent_spec__table_name = null, \?string $parent_spec__parent_name = null, \?string $parent_field_name = null, \?string $parent_spec__field_name = null, boolean $numeric_record_set_ids = true, boolean $numeric_category_set_ids = true, \?object $db = null) : array
package core

Parameters

$filter

string

The filter

$ids_and_parents

array

A map between record-set IDs and record-set parent-category-IDs

$parent_spec__table_name

\?string

The database's table that contains parent/child relationships in the record-set's category-set (the category-set is equal to the record-set if we're matching categories, but not if we're matching entries) (null: don't support subtree [*-style] searches)

$parent_spec__parent_name

\?string

The database's field name for the category-set's parent-category-ID (null: don't support subtree [*-style] searches beyond the tree base)

$parent_field_name

\?string

The database's field name for the record-set's container-category specifier (null: don't support subtree [*-style] searches)

$parent_spec__field_name

\?string

The database's field name for the category-set's category-ID (null: don't support subtree [*-style] searches beyond the tree base)

$numeric_record_set_ids

boolean

Whether the record-set IDs are numeric

$numeric_category_set_ids

boolean

Whether the category-set IDs are numeric

$db

\?object

Database connection to use (null: website)

Returns

arrayA list of ID numbers

Turn an Selectcode (a filter specifying which records to match) into an SQL query fragment.

selectcode_to_sqlfragment(string $filter, string $field_name, \?string $parent_spec__table_name = null, \?string $parent_spec__parent_name = null, \?string $parent_field_name = null, \?string $parent_spec__field_name = null, boolean $numeric_record_set_ids = true, boolean $numeric_category_set_ids = true, \?object $db = null) : string
package core

Parameters

$filter

string

The filter

$field_name

string

The database's ID field for the record-set we're matching. E.g. 'id'.

$parent_spec__table_name

\?string

The database's table that contains parent/child relationships in the record-set's category-set (the category-set is equal to the record-set if we're matching categories, but not if we're matching entries) (null: don't support subtree [*-style] searches). E.g. 'categories'.

$parent_spec__parent_name

\?string

The database's field name for the category-set's parent-category-ID (null: don't support subtree [*-style] searches beyond the tree base). E.g. 'parent_id'.

$parent_field_name

\?string

The database's field name for the record-set's container-category specifier (null: don't support subtree [*-style] searches). E.g. 'cat'.

$parent_spec__field_name

\?string

The database's field name for the category-set's category-ID (null: don't support subtree [*-style] searches beyond the tree base). E.g. 'id'.

$numeric_record_set_ids

boolean

Whether the record-set IDs are numeric

$numeric_category_set_ids

boolean

Whether the category-set IDs are numeric

$db

\?object

Database connection to use (null: website)

Returns

stringSQL query fragment. Note that brackets will be put around this automatically if required, so there's no need to do this yourself.

Run some routines needed for semi-dev-mode, during startup.

semi_dev_mode_startup() 
package core

Send a "your content has been validated" notification out to the submitter of some content. Only call if this is true ;).

send_content_validated_notification(\ID_TEXT $content_type, \ID_TEXT $content_id) 
package core

Parameters

$content_type

\ID_TEXT

Content type

$content_id

\ID_TEXT

Content ID

Send (by e-mail) a validation request for a submitted item to the admin.

send_validation_request(\ID_TEXT $type, \?ID_TEXT $table, boolean $non_integer_id, \ID_TEXT $id, \Tempcode $url, \?MEMBER $member_id = null
package core

Parameters

$type

\ID_TEXT

The validation request will say one of this type has been submitted. By convention it is the language code of what was done, e.g. ADD_DOWNLOAD

$table

\?ID_TEXT

The table saved into (null: unknown)

$non_integer_id

boolean

Whether the ID field is not an integer

$id

\ID_TEXT

The validation request will say this ID has been submitted

$url

\Tempcode

The validation request will link to this URL

$member_id

\?MEMBER

Member doing the submitting (null: current member)

Get template fields to insert into a form page, for manipulation of seo fields.

seo_get_fields(\ID_TEXT $type, \?ID_TEXT $id = null, boolean $show_header = true) : \Tempcode
package core

Parameters

$type

\ID_TEXT

The type of resource (e.g. download)

$id

\?ID_TEXT

The ID of the resource (null: adding)

$show_header

boolean

Whether to show a header

Returns

\TempcodeForm page Tempcode fragment

Clear caching for a particular seo entry.

seo_meta_clear_caching(\ID_TEXT $type, \ID_TEXT $id) 
package core

Parameters

$type

\ID_TEXT

The type of resource (e.g. download)

$id

\ID_TEXT

The ID of the resource

Erase a seo entry.

seo_meta_erase_storage(\ID_TEXT $type, \ID_TEXT $id, boolean $do_decache = true

.. as these shouldn't be left hanging around once content is deleted.

package core

Parameters

$type

\ID_TEXT

The type of resource (e.g. download)

$id

\ID_TEXT

The ID of the resource

$do_decache

boolean

Whether to clear caching for this too

Get meta information for specified resource

seo_meta_get_for(\ID_TEXT $type, \ID_TEXT $id) : array
package core

Parameters

$type

\ID_TEXT

The type of resource (e.g. download)

$id

\ID_TEXT

The ID of the resource

Returns

arrayA pair: The first element is the meta keyword string for the specified resource, and the other is the meta description string.

Load the specified resource's meta information into the system for use on this page.

seo_meta_load_for(\ID_TEXT $type, \ID_TEXT $id, \?string $title = null

Also, if the title is specified then this is used for the page title.

package core
sets_output_state

Parameters

$type

\ID_TEXT

The type of resource (e.g. download)

$id

\ID_TEXT

The ID of the resource

$title

\?string

The page-specific title to use, in Comcode or plain-text format with possible HTML entities included [Comcode will later be stripped] (null: none)

Explictly sets the meta information for the specified resource.

seo_meta_set_for_explicit(\ID_TEXT $type, \ID_TEXT $id, \SHORT_TEXT $keywords, \SHORT_TEXT $description) 
package core

Parameters

$type

\ID_TEXT

The type of resource (e.g. download)

$id

\ID_TEXT

The ID of the resource

$keywords

\SHORT_TEXT

The keywords to use

$description

\SHORT_TEXT

The description to use

Sets the meta information for the specified resource, by auto-summarisation from the given parameters.

seo_meta_set_for_implicit(\ID_TEXT $type, \ID_TEXT $id, array $keyword_sources, \SHORT_TEXT $description) : \SHORT_TEXT
package core

Parameters

$type

\ID_TEXT

The type of resource (e.g. download)

$id

\ID_TEXT

The ID of the resource

$keyword_sources

array

Array of content strings to summarise from

$description

\SHORT_TEXT

The description to use

Returns

\SHORT_TEXTKeyword string generated (it's also saved in the DB, so usually you won't want to collect this)

Assuming that permission details are POSTed, set the permissions for the specified category, in the current page

set_category_permissions_from_environment(\ID_TEXT $module, \ID_TEXT $category, \?ID_TEXT $page = null
package core

Parameters

$module

\ID_TEXT

The ID code for the module being checked for category access

$category

\ID_TEXT

The ID code for the category being checked for access (often, a number cast to a string)

$page

\?ID_TEXT

The page this is for (null: current page)

Change whatever global context that is required in order to run from a different context.

set_execution_context(array $new_get, \ID_TEXT $new_zone = '_SEARCH', \ID_TEXT $new_current_script = 'index', boolean $erase_keep_also = false) : array
package core
sets_input_state

Parameters

$new_get

array

The URL component map (must contain 'page').

$new_zone

\ID_TEXT

The zone.

$new_current_script

\ID_TEXT

The running script.

$erase_keep_also

boolean

Whether to get rid of keep_ variables in current URL.

Returns

arrayA list of parameters that would be required to be passed back to reset the state.

Set the feed (RSS/Atom) URL.

set_feed_url(\URLPATH $url) 
package core
sets_output_state

Parameters

$url

\URLPATH

The URL

Set the helper panel text.

set_helper_panel_text(\Tempcode $text, boolean $append = true, boolean $put_in_box = true
package core
sets_output_state

Parameters

$text

\Tempcode

The text

$append

boolean

Whether to append

$put_in_box

boolean

Whether to add a box around the parameter

Set the helper panel tutorial.

set_helper_panel_tutorial(\ID_TEXT $tutorial) 
package core
sets_output_state

Parameters

$tutorial

\ID_TEXT

The page name of the tutorial (must be an existing one on the brand site, i.e. compo.sr)

Set the HTTP status code for the request.

set_http_status_code(string $code) 
package core
sets_output_state

Parameters

$code

string

The HTTP status code (should be numeric)

Set invisibility on the current user.

set_invisibility(boolean $make_invisible = true
package core

Parameters

$make_invisible

boolean

Whether to make the current user invisible (true=make invisible, false=make visible)

Set if a mass-import is in progress.

set_mass_import_mode(boolean $doing_mass_import = true
package core

Parameters

$doing_mass_import

boolean

If it is

Put a member into a usergroup temporarily. Note that if people are subsequently removed from the usergroup they won't be put back in; this allows the admin to essentially cancel the subscription - however, if it is then extended, they do keep the time they had before too.

set_member_group_timeout(\MEMBER $member_id, \GROUP $group_id, \TIME $timestamp, boolean $prefer_for_primary_group = false
package core

Parameters

$member_id

\MEMBER

The member going in the usergroup.

$group_id

\GROUP

The usergroup.

$timestamp

\TIME

The expiry timestamp.

$prefer_for_primary_group

boolean

Whether to put the member into as a primary group if this is a new temporary membership (it is recommended to NOT use this, since we don't track the source group and hence on expiry the member is put back to the first default group - but also generally you probably don't want to box yourself in with moving people's primary group, it ties your future flexibility down a lot).

Set a configuration option with the specified values.

set_option(\ID_TEXT $name, \LONG_TEXT $value, \BINARY $will_be_formally_set = 1

Note that you may wish to also empty the template cache after running this function. Config options may have been set into template(s).

package core

Parameters

$name

\ID_TEXT

The name of the value

$value

\LONG_TEXT

The value

$will_be_formally_set

\BINARY

Whether this was a human-set value

Assuming that permission details are POSTed, set the permissions for the specified category, in the current page

set_page_permissions_from_environment(\ID_TEXT $zone, \ID_TEXT $page) 
package core

Parameters

$zone

\ID_TEXT

The ID code for the zone

$page

\ID_TEXT

The ID code for the page

Sets the privilege of a usergroup

set_privilege(\GROUP $group_id, \ID_TEXT $permission, boolean $value, \?ID_TEXT $page = null, \?ID_TEXT $category_type = null, \?ID_TEXT $category_name = null
package core

Parameters

$group_id

\GROUP

The usergroup having the permission set

$permission

\ID_TEXT

The codename of the permission

$value

boolean

Whether the usergroup has the permission

$page

\?ID_TEXT

The ID code for the page being checked (null: current page)

$category_type

\?ID_TEXT

The category-type for the permission (null: none required)

$category_name

\?ID_TEXT

The category-name/value for the permission (null: none required)

Set the session ID of the user.

set_session_id(\ID_TEXT $id, boolean $guest_session = false
package core
sets_output_state

Parameters

$id

\ID_TEXT

The session ID

$guest_session

boolean

Whether this is a guest session (guest sessions will use persistent cookies)

Sets the short title, used for screen header text if set.

set_short_title(string $title) 

Does not do anything if output streaming is on and already started.

package core
sets_output_state

Parameters

$title

string

The short title

Specify if errors should be thrown, rather than resulting in HTML exit screens.

set_throw_errors(boolean $_throwing_errors = true
package core

Parameters

$_throwing_errors

boolean

Whether we should throw errors

Set a URL moniker for a resource.

set_url_moniker(\ID_TEXT $content_type, \ID_TEXT $content_id, \?array $fields_to_skip = null, \?ID_TEXT $new_content_id = null
package core

Parameters

$content_type

\ID_TEXT

The type of resource (e.g. download)

$content_id

\ID_TEXT

The old ID of the resource

$fields_to_skip

\?array

List of fields to NOT take in (null: empty list)

$new_content_id

\?ID_TEXT

The new ID of the resource (null: not being renamed)

Set the specified situational value to the specified value.

set_value(\ID_TEXT $name, \?SHORT_TEXT $value, boolean $elective_or_lengthy = false) : \SHORT_TEXT
package core

Parameters

$name

\ID_TEXT

The name of the value

$value

\?SHORT_TEXT

The value (null: delete)

$elective_or_lengthy

boolean

Whether this value is an elective/lengthy one. Use this for getting & setting if you don't want it to be loaded up in advance for every page view (in bulk alongside other values), or if the value may be more than 255 characters. Performance tradeoff: frequently used values should not be elective, infrequently used values should be elective.

Returns

\SHORT_TEXTThe value just set, same as $value (just as a niceity so that Commandr users can see something "happen")

Find whether a file is known to be something that should/could be there but isn't a Composr distribution file, or for some other reason should be ignored.

should_ignore_file(string $filepath, integer $bitmask = 0, integer $bitmask_defaults = 0) : boolean
package core

Parameters

$filepath

string

File path (relative to Composr base directory)

$bitmask

integer

Bitmask of extra stuff to ignore (see IGNORE_* constants)

$bitmask_defaults

integer

Set this to 0 if you don't want the default IGNORE_* constants to carry through

Returns

booleanWhether it should be ignored

Output whatever memory points we collected up.

show_memory_points() 
package core

Do a wildcard match by converting to a regular expression.

simulated_wildcard_match(string $context, string $word, boolean $full_cover = false) : boolean
package core

Parameters

$context

string

The haystack

$word

string

The needle (a wildcard expression)

$full_cover

boolean

Whether full-coverance is required

Returns

booleanWhether we have a match

The do-next manager for after content management.

sitemap_do_next_manager(\Tempcode $title, \?ID_TEXT $page, \ID_TEXT $zone, \Tempcode $completion_text) : \Tempcode
package core

Parameters

$title

\Tempcode

The title (output of get_screen_title)

$page

\?ID_TEXT

The name of the page just handled (null: none)

$zone

\ID_TEXT

The name of the zone just handled (blank: none/welcome-zone)

$completion_text

\Tempcode

The text to show (blank: default)

Returns

\TempcodeThe UI

AJAX script for dynamically extended Sitemap.

sitemap_script() 
package core

AJAX script for dynamically extended Sitemap: loading.

sitemap_script_loading() 
package core

AJAX script for dynamically extended Sitemap: saving.

sitemap_script_saving() 
package core

Top level function to (re)generate a Sitemap (xml file, Google-style).

sitemap_xml_build() 
package core

Find whether we can skip the normal preservation of a keep value, for whatever reason.

skippable_keep(string $key, string $val) : boolean
package core

Parameters

$key

string

Parameter name

$val

string

Parameter value

Returns

booleanWhether we can skip it

Assign a redirect to the specified URL, with no visual component.

smart_redirect(mixed $url) 

If possible, use an HTTP header; but if output has already started, use a meta tag.

package core
sets_output_state

Parameters

$url

mixed

Refresh to this URL (URLPATH or Tempcode URL)

Sort a list of maps by a particular key ID in the maps.

sort_maps_by(array $rows, mixed $sort_keys) 
package core

Parameters

$rows

array

List of maps to sort

$sort_keys

mixed

Either an integer sort key (to sort by integer key ID of contained arrays) or a Comma-separated list of sort keys (to sort by string key ID of contained arrays; prefix '!' a key to reverse the sort order for it).

Sort a list of maps by the string length of a particular key ID in the maps.

sort_maps_by__strlen(array $rows, mixed $sort_key) 
package core

Parameters

$rows

array

List of maps to sort

$sort_key

mixed

Either an integer sort key (to sort by integer key ID of contained arrays) or a String sort key (to sort by string key ID of contained arrays).

Sort search results as returned by the search hook.

sort_search_results(array $hook_results, array $results, string $direction) : array
package core
set ASC DESC

Parameters

$hook_results

array

Search results from the search hook, assumed already sorted

$results

array

Existing array of results (originally starts blank)

$direction

string

Sort direction

Returns

arraySorted results

Handle special page type output.

special_page_types(\ID_TEXT $special_page_type, \Tempcode $out, string $out_evaluated) 
package core
set query templates tree lang

Parameters

$special_page_type

\ID_TEXT

The special page type.

$out

\Tempcode

The normal script Tempcode output

$out_evaluated

string

The normal script evaluated output

If possible dump the user to 100% static caching.

static_cache(integer $mode) 
package core

Parameters

$mode

integer

The mode

Get a well formed URL equivalent to the current URL. Reads direct from the environment and does no clever mapping at all. This function should rarely be used.

static_cache__get_self_url_easy() : \URLPATH
package core

Returns

\URLPATHThe URL

Get the URL we are considering static caching against.

static_cache_current_url() : \URLPATH
package core

Returns

\URLPATHThe URL

Simple function to evaluate some Tempcode. Very rarely to be used, only if you can't call a method (e.g. you are copying direct into an array, such as in block caching).

static_evaluate_tempcode(\Tempcode $ob) : string
package core

Parameters

$ob

\Tempcode

Tempcode object

Returns

stringEvaluated string

Save metadata into content type's custom fields, by looking for fields named after the EXIF/EXIF-emulated metadata (specifically in English).

store_exif(\ID_TEXT $content_type, \ID_TEXT $content_id, array $exif, \?array $map = null

Spaces may be added to the names to make them prettier, but otherwise they must be the same. Designed to be used by headless-importers, e.g. bulk importing of media files, to make the process a bit smarter.

package core

Parameters

$content_type

\ID_TEXT

The content type

$content_id

\ID_TEXT

The content ID

$exif

array

The EXIF data

$map

\?array

Extra metadata to store, against explicit field IDs (null: none)

Convert some HTML to plain text.

strip_html(string $in) : string
package core

Parameters

$in

string

HTML

Returns

stringPlain text

Take some Tempcode and pre-process it for Tempcode portions encapsulated within comments (or similar).

substitute_comment_encapsulated_tempcode(string $data) : string

This is done so syntax-highlighters don't break, and WYSIWYG-editors don't corrupt the Tempcode.

package core

Parameters

$data

string

Input Tempcode

Returns

stringOutput Tempcode

Give the user an option to see a stack trace by adding in a link, but only if they have permission

suggest_fatalistic() 
package core

Called when content is added, or edited/moved, based upon a new form field that specifies what moniker to use.

suggest_new_idmoniker_for(\ID_TEXT $page, \ID_TEXT $type, \ID_TEXT $id, \ID_TEXT $zone, string $moniker_src, boolean $is_new = false) : string
package core

Parameters

$page

\ID_TEXT

Page name.

$type

\ID_TEXT

Screen type code.

$id

\ID_TEXT

Resource ID.

$zone

\ID_TEXT

The URL zone name (only used for Comcode Page URL monikers).

$moniker_src

string

String from which a moniker will be chosen (may not be blank).

$is_new

boolean

Whether we are sure this is a new moniker (makes things more efficient, saves a query).

Returns

stringThe chosen moniker.

This will create a new Tempcode object that is containing a single specifed symbol

symbol_tempcode(\ID_TEXT $symbol, \?array $parameters = null, \?array $escape = null) : \Tempcode
package core

Parameters

$symbol

\ID_TEXT

The ID of the symbol to use

$parameters

\?array

Symbol parameters (null: none)

$escape

\?array

Escaping (null: none)

Returns

\TempcodeA symbol Tempcode object

Handle truncation symbols in all their complexity

symbol_truncator(array $param, string $type, \?mixed $tooltip_if_truncated = null) : string
package core
set left right spread

Parameters

$param

array

Parameters passed to the symbol (0=text, 1=amount, 2=tooltip?, 3=is_html?, 4=use as grammatical length rather than HTML byte length, 5=fractional-deviation-tolerance for grammar-preservation)

$type

string

The type of truncation to do

$tooltip_if_truncated

\?mixed

Tooltip to add on, but only if we end up creating our own tooltip (null: none)

Returns

stringThe result.

Provides an override point for file synchronisation between mirrored servers. Called after any file creation, deletion or edit.

sync_file(\PATH $filename) 
package core

Parameters

$filename

\PATH

File/directory name to sync on (full path)

Provides an override point for file-move synchronisation between mirrored servers. Called after any rename or move action.

sync_file_move(\PATH $old, \PATH $new) 
package core

Parameters

$old

\PATH

File/directory name to move from (may be full or relative path)

$new

\PATH

File/directory name to move to (may be full or relative path)

Update the .htaccess file with the latest zone names.

sync_htaccess_with_zones() 
package core

Syndicate human-intended descriptions of activities performed to the internal wall, and external listeners.

syndicate_described_activity(string $a_language_string_code = '', string $a_label_1 = '', string $a_label_2 = '', string $a_label_3 = '', string $a_page_link_1 = '', string $a_page_link_2 = '', string $a_page_link_3 = '', string $a_addon = '', \BINARY $a_is_public = 1, \?MEMBER $a_member_id = null, boolean $sitewide_too = false, \?MEMBER $a_also_involving = null
package core

Parameters

$a_language_string_code

string

Language string code

$a_label_1

string

Label 1 (given as a parameter to the language string code)

$a_label_2

string

Label 2 (given as a parameter to the language string code)

$a_label_3

string

Label 3 (given as a parameter to the language string code)

$a_page_link_1

string

Page-link 1

$a_page_link_2

string

Page-link 2

$a_page_link_3

string

Page-link 3

$a_addon

string

Addon that caused the event

$a_is_public

\BINARY

Whether this post should be public or friends-only

$a_member_id

\?MEMBER

Member being written for (null: current member)

$sitewide_too

boolean

Whether to push this out as a site event if user requested

$a_also_involving

\?MEMBER

Member also 'intimately' involved, such as a content submitter who is a friend (null: none)

Syndicate a spammer report out to wherever we can.

syndicate_spammer_report(\IP $ip_addr, \ID_TEXT $username, \EMAIL $email, string $reason, boolean $trigger_error = false
package core

Parameters

$ip_addr

\IP

IP address to report

$username

\ID_TEXT

Username address to report

$email

\EMAIL

Email address to report

$reason

string

The reason for the report (blank: none)

$trigger_error

boolean

Whether to emit a Composr error, on error. Should not be 'true' for automatic spammer reports, as the spammer should not see the submission process in action!

Are we currently running HTTPS.

tacit_https() : boolean
package core

Returns

booleanIf we are

Add a file to the specified TAR file.

tar_add_file(array $resource, \PATH $target_path, string $data, integer $_mode = 420, \?TIME $_mtime = null, boolean $data_is_path = false, boolean $return_on_errors = false) : integer
package core

Parameters

$resource

array

The TAR file handle

$target_path

\PATH

The relative path to where we wish to add the file to the archive (including filename)

$data

string

The data of the file to add

$_mode

integer

The file mode (permissions)

$_mtime

\?TIME

The modification time we wish for our file (null: now)

$data_is_path

boolean

Whether the $data variable is actually a full file path

$return_on_errors

boolean

Whether to return on errors

Returns

integerOffset of the file in the TAR

Add a folder to the TAR archive

tar_add_folder(array $resource, \?resource $logfile, \PATH $path, \?integer $max_size = null, \PATH $subpath = '', \?array $avoid_backing_up = null, \?array $root_only_dirs = null, boolean $tick = false, boolean $all_files = false
package core

Parameters

$resource

array

The TAR file handle

$logfile

\?resource

The logfile to write to (null: no logging)

$path

\PATH

The full path to the folder to add

$max_size

\?integer

The maximum file size to add (null: no limit)

$subpath

\PATH

The subpath relative to the path (should be left as the default '', as this is used for the recursion to distinguish the adding base path from where it's currently looking)

$avoid_backing_up

\?array

A map (filename=>true) of files to not back up (null: none)

$root_only_dirs

\?array

A list of directories ONLY to back up from the root (null: no restriction)

$tick

boolean

Whether to output spaces as we go to keep the connection alive

$all_files

boolean

Whether to not skip "special files" (ones not normally archive)

Add a folder to the TAR archive, however only store files modifed after a threshold time. It is incremental (incremental backup), by comparing against a threshold before adding a file (threshold being time of last backup)

tar_add_folder_incremental(array $resource, \?resource $logfile, \PATH $path, \TIME $threshold, \?integer $max_size, \PATH $subpath = '', boolean $all_files = false) : array
package core

Parameters

$resource

array

The TAR file handle

$logfile

\?resource

The logfile to write to (null: no logging)

$path

\PATH

The full path to the folder to add

$threshold

\TIME

The threshold time

$max_size

\?integer

The maximum file size to add (null: no limit)

$subpath

\PATH

The subpath relative to the path (should be left as the default '', as this is used for the recursion to distinguish the adding base path from where it's currently looking)

$all_files

boolean

Whether to not skip "special files" (ones not normally archive)

Returns

arrayA list of maps that stores 'path', 'mode' and 'size', for each newly added file in the archive

Close an open TAR resource.

tar_close(array $resource) 
package core

Parameters

$resource

array

The TAR file handle to close

Find the checksum specified in a TAR header

tar_crc(string $header) : integer
package core

Parameters

$header

string

The header from a TAR file

Returns

integerThe checksum

Extract all the files in the specified TAR file to the specified path.

tar_extract_to_folder(array $resource, \PATH $path, boolean $use_afm = false, \?array $files = null, boolean $comcode_backups = false
package core

Parameters

$resource

array

The TAR file handle

$path

\PATH

The path to the folder to extract to, relative to the base directory

$use_afm

boolean

Whether to extract via the AFM (assumes AFM has been set up prior to this function call)

$files

\?array

The files to extract (null: all)

$comcode_backups

boolean

Whether to take backups of Comcode pages

Return the root directory from the specified TAR file. Note that there are folders in here, and they will end '/'.

tar_get_directory(array $resource, boolean $tolerate_errors = false) : \?array
package core

Parameters

$resource

array

The TAR file handle

$tolerate_errors

boolean

Whether to tolerate errors (returns NULL if error)

Returns

\?arrayA list of maps that stores 'path', 'mode', 'size' and 'mtime', for each file in the archive (null: error)

Get the contents of the specified file in the specified TAR.

tar_get_file(array $resource, \PATH $path, boolean $tolerate_errors = false, \?PATH $write_data_to = null) : \?array
package core

Parameters

$resource

array

The TAR file handle

$path

\PATH

The full path to the file we want to get

$tolerate_errors

boolean

Whether to tolerate errors (returns NULL if error)

$write_data_to

\?PATH

Write data to here (null: return within array)

Returns

\?arrayA map, containing 'data' (the file), 'size' (the filesize), 'mtime' (the modification timestamp), and 'mode' (the permissions) (null: not found / TAR possibly corrupt if we turned tolerate errors on)

Open up a TAR archive, and return the resource.

tar_open(\?PATH $path, string $mode) : array
package core
set rb wb w+b

Parameters

$path

\?PATH

The path to the TAR archive (null: write out directly to stdout)

$mode

string

The mode to open the TAR archive (rb=read, wb=write)

Returns

arrayThe TAR file handle

Script to execute a described task.

tasks_script() 
package core

Convert template text into Tempcode format.

template_to_tempcode(string $text, integer $symbol_pos = 0, boolean $inside_directive = false, \ID_TEXT $codename = '', \?ID_TEXT $theme = null, \?ID_TEXT $lang = null, boolean $tolerate_errors = false) : mixed
package core

Parameters

$text

string

The template text

$symbol_pos

integer

The position we are looking at in the text

$inside_directive

boolean

Whether this text is infact a directive, about to be put in the context of a wider template

$codename

\ID_TEXT

The codename of the template (e.g. foo)

$theme

\?ID_TEXT

The theme it is for (null: current theme)

$lang

\?ID_TEXT

The language it is for (null: current language)

$tolerate_errors

boolean

Whether to tolerate errors

Returns

mixedThe converted/compiled template as Tempcode, OR if a directive, encoded directive information

Test password strength.

test_password(string $password, string $username = '') : integer
package core

Parameters

$password

string

The password to check

$username

string

The username that will go with the password

Returns

integerPassword strength (1-10)

Find whether we should throw errors, rather than create HTML exit screens with the error messages / correction screens.

throwing_errors() : boolean
package core

Returns

booleanWhether to are throwing errors

Turn a boring codename, into a "pretty" title.

titleify(\ID_TEXT $boring) : string
package core

Parameters

$boring

\ID_TEXT

The codename

Returns

stringThe title

For a UTC timestamp, find the equivalent virtualised local timestamp.

tz_time(\TIME $time, string $zone) : \TIME
package core

Parameters

$time

\TIME

UTC time

$zone

string

Timezone (boring style)

Returns

\TIMEVirtualised local time

Unban the specified IP address.

unban_ip(\IP $ip) 
package core

Parameters

$ip

\IP

The IP address to unban

Convert a unicode character number to a HTML-entity enabled string, using lower ASCII characters where possible.

unichr(integer $c) : \~string
package core

Parameters

$c

integer

Character number.

Returns

\~stringConverted data (false: could not convert).

Convert a unicode character number to a unicode string. Callback for preg_replace.

unichrm(array $matches) : \~string
package core

Parameters

$matches

array

Regular expression match array.

Returns

\~stringConverted data (false: could not convert).

Convert a unicode character number to a unicode string. Callback for preg_replace.

unichrm_hex(array $matches) : \~string
package core

Parameters

$matches

array

Regular expression match array.

Returns

\~stringConverted data (false: could not convert).

This function totally uninstalls a block from the system. Yet again, you should not need to use this function.

uninstall_block(\ID_TEXT $block) 
package core

Parameters

$block

\ID_TEXT

The name of the block to uninstall

Completely uninstall the specified module from the system.

uninstall_module(\ID_TEXT $zone, \ID_TEXT $module) 
package core

Parameters

$zone

\ID_TEXT

The zone name

$module

\ID_TEXT

The module name

Make sure that lines are seperated by "\n", with no "\r"'s there at all. For Mac data, this will be a flip scenario. For Linux data this will be a null operation. For windows data this will be change from "\r\n" to just "\n". For a realistic scenario, data could have originated on all kinds of platforms, with some editors converting, some situations being inter-platform, and general confusion. Don't make blind assumptions - use this function to clean data, then write clean code that only considers "\n"'s.

unixify_line_format(string $in, \?ID_TEXT $desired_charset = null, boolean $html = false, boolean $from_disk = false) : string
package core

Parameters

$in

string

The data to clean

$desired_charset

\?ID_TEXT

The character set it should be in. We don't do any real conversions using this, only make sure that common problems with fed ISO-8859-1 data are resolved (null: output character set)

$html

boolean

Whether we are cleaning for HTML rather than Comcode/plain-text

$from_disk

boolean

Whether the file is loaded from disk (less conversion needed)

Returns

stringThe cleaned data

Take some parsed Filtercode search filters into the string format (i.e. reverse of parse_filtercode).

unparse_filtercode(array $parsed) : string
package core

Parameters

$parsed

array

Parsed structure

Returns

stringString-based search filter

Update the details in our bounce storage table, by looking at received bounces.

update_bounce_storage(string $server, integer $port, string $folder, string $username, string $password, \?TIME $since = null
package core

Parameters

$server

string

The IMAP server hostname.

$port

integer

The IMAP port.

$folder

string

The IMAP inbox identifier.

$username

string

The IMAP username.

$password

string

The IMAP password.

$since

\?TIME

Only find bounces since this date (null: 8 weeks ago). This is approximate, we will actually look from a bit further back to compensate for possible timezone differences.

Update a catalogue content field reference, to a new value.

update_catalogue_content_ref(\ID_TEXT $type, \ID_TEXT $from, \ID_TEXT $to) 
package core

Parameters

$type

\ID_TEXT

Content type

$from

\ID_TEXT

Old value

$to

\ID_TEXT

New value

Increment the specified stored value, by the specified amount.

update_stat(\ID_TEXT $stat, integer $increment) 
package core

Parameters

$stat

\ID_TEXT

The codename for the stat

$increment

integer

What to increment the statistic by

Upgrades a block to the latest version available on your Composr installation. [b]This function can only upgrade to the latest version put into the block directory.[/b] You should not need to use this function.

upgrade_block(\ID_TEXT $block) : integer
package core

Parameters

$block

\ID_TEXT

The name of the block to upgrade

Returns

integer0=No upgrade. -2=Not installed, 1=Upgrade

Upgrade the specified module.

upgrade_module(\ID_TEXT $zone, \ID_TEXT $module) : integer
package core

Parameters

$zone

\ID_TEXT

The zone name

$module

\ID_TEXT

The module name

Returns

integer0=No upgrade. -2=Not installed, 1=Upgrade

Save syndication to a web service (typically via oAuth, but abstracted within the upload_syndication hooks).

upload_syndication_auth_script() 
package core

Find if upload syndication will happen. Tell's us we do not need to worry about quota.

upload_will_syndicate(\ID_TEXT $name) : boolean
package core

Parameters

$name

\ID_TEXT

Upload field name.

Returns

booleanWhether it will?

Find if the specified URL is local or not (actually, if it is relative). This is often used by code that wishes to use file system functions on URLs (Composr will store such relative local URLs for uploads, etc)

url_is_local(\URLPATH $url) : boolean
package core

Parameters

$url

\URLPATH

The URL to check

Returns

booleanWhether the URL is local

Find whether URL monikers are enabled.

url_monikers_enabled() : boolean
package core

Returns

booleanWhether URL monikers are enabled.

Takes a URL, and converts it into a file system storable filename. This is used to cache URL contents to the servers filesystem.

url_to_filename(\URLPATH $url_full) : string
package core

Parameters

$url_full

\URLPATH

The URL to convert to an encoded filename

Returns

stringA usable filename based on the URL

URL'ise specially encoded text-acceptance language strings.

urlise_lang(string $string, mixed $url, string $title = '', boolean $new_window = false) : \Tempcode
package core

Parameters

$string

string

The language string

$url

mixed

The URL (either Tempcode or string)

$title

string

The title of the hyperlink

$new_window

boolean

Whether to use a new window

Returns

\TempcodeThe encoded version

Get the user's currently selected language.

user_lang() : \LANGUAGE_NAME
package core

Returns

\LANGUAGE_NAMEThe user's current language

Convert a user timestamp to a UTC timestamp. This is not a function to use much- you probably want utctime_to_usertime.

usertime_to_utctime(\?TIME $timestamp = null, \?MEMBER $member = null) : \TIME

What complicate understanding of matters is that "user time" is not the timestamp that would exist on a user's PC, as all timestamps are meant to be stored in UTC. "user time" is offsetted to compensate, a virtual construct.

package core

Parameters

$timestamp

\?TIME

Input timestamp (null: now)

$member

\?MEMBER

Member for which the date is being rendered (null: current member)

Returns

\TIMEOutput timestamp

Convert a UTC timestamp to a user timestamp. The user timestamp should not be pumped through get_timezoned_date as this already performs the conversions internally.

utctime_to_usertime(\?TIME $timestamp = null, \?MEMBER $member = null) : \TIME

What complicate understanding of matters is that "user time" is not the timestamp that would exist on a user's PC, as all timestamps are meant to be stored in UTC. "user time" is offsetted to compensate, a virtual construct.

package core

Parameters

$timestamp

\?TIME

Input timestamp (null: now)

$member

\?MEMBER

Member for which the date is being rendered (null: current member)

Returns

\TIMEOutput timestamp

Turn utf-8 characters into unicode HTML entities. Useful as GD truetype functions need this. Based on function in PHP code comments.

utf8tohtml(string $utf8) : string
package core

Parameters

$utf8

string

Input.

Returns

stringOutput.

This is a less-revealing alternative to fatal_exit, that is used for user-errors/common-corruption-scenarios

warn_exit(mixed $text, boolean $support_match_key_messages = false) : mixed
package core

Parameters

$text

mixed

The error message (string or Tempcode)

$support_match_key_messages

boolean

Whether match key messages / redirects should be supported

Returns

mixedNever returns (i.e. exits)

Exit with a message about word-filtering.

warn_exit_wordfilter(\?ID_TEXT $name, \Tempcode $message) : mixed
package core

Parameters

$name

\?ID_TEXT

The name of the parameter this is coming from. Certain parameters are not checked, for reasons of efficiency (avoiding loading whole word check list if not needed) (null: don't know param, do not check to avoid)

$message

\Tempcode

Error message

Returns

mixedNever returns (i.e. exits)

Get the Tempcode for a warn page.

warn_screen(\Tempcode $title, mixed $text, boolean $provide_back = true, boolean $support_match_key_messages = false) : \Tempcode
package core

Parameters

$title

\Tempcode

The title of the warn page

$text

mixed

The text to put on the warn page (either Tempcode or string)

$provide_back

boolean

Whether to provide a back button

$support_match_key_messages

boolean

Whether match key messages / redirects should be supported

Returns

\TempcodeThe warn page

Guard for entity_utf8_decode. Checks that the data can be stripped so there is no unicode left. Either the htmlentities function must convert mechanically to entity-characters or all higher ascii character codes (which are actually unicode control codes in a unicode interpretation) that are used happen to be linked to named entities.

will_be_unicode_neutered(string $data) : boolean

PHP's utf-8 support may not be great. For example, we have seen emoji characters not converting.

package core

Parameters

$data

string

Data to check.

Returns

booleanWhether we are good to execute entity_utf8_decode.

Display some raw text so that it is repeated as raw visually in HTML.

with_whitespace(string $in) : \Tempcode
package core

Parameters

$in

string

Input

Returns

\TempcodeOutput

Get a word-filtered version of the specified text.

wordfilter_text(string $text) : string
package core

Parameters

$text

string

Text to filter

Returns

stringFiltered version of the input text

Find a member from their IP address. Unlike plain $GLOBALS['FORUM_DRIVER']->probe_ip, it has the benefit of looking in the adminlogs table also.

wrap_probe_ip(\IP $ip) : array
package core

Parameters

$ip

\IP

The IP address to probe

Returns

arrayThe members found

Write out a static cache file.

write_static_cache_file(\PATH $fast_cache_path, string $out_evaluated, boolean $support_gzip) 
package core

Parameters

$fast_cache_path

\PATH

Cache file path

$out_evaluated

string

Cache contents

$support_gzip

boolean

Whether to allow gzipping

Write a text file, using the _custom system

write_text_file(string $codename, \?LANGUAGE_NAME $lang, string $out) 
package core

Parameters

$codename

string

The file name (without .txt)

$lang

\?LANGUAGE_NAME

The language to write for (null: none) (blank: search)

$out

string

The data to write

XHTML-aware substring extraction. Note that it will strip images, linebreaks, rules, etc - it's intended really for inline XHTML.

xhtml_substr(string $html, integer $from, \?integer $length = null, boolean $literal_pos = false, boolean $ellipses = false, float $grammar_completeness_tolerance = 0.0) : string
package core

Parameters

$html

string

The text to perform on.

$from

integer

The start position of the cut (HTML tags will be taken from before this though).

$length

\?integer

The length you want the concatenated text to be (null: go to end).

$literal_pos

boolean

Whether to do a substr based on literal position in XHTML, rather than based on number of visible characters.

$ellipses

boolean

Whether to add ellipses.

$grammar_completeness_tolerance

float

A fraction of the length we may exceed by in order to maintain grammar tolerance (finish sentences, finish paragraphs, finish the whole thing).

Returns

stringThe result.

Function that 'fixes' HTML (or bad XHTML) enough for it to pass most basic structural webstandards checking.

xhtmlise_html(string $html, boolean $definitely_want = false, boolean $snippet = false) : string
package core

Parameters

$html

string

The XHTML string to convert to XHTML

$definitely_want

boolean

Whether to force a repair even if we aren't enforcing XHTML strictness

$snippet

boolean

Whether this is a partial snippet of HTML, embeddable in some unknown context

Returns

stringThe converted string

Do a highly-simplified XML-RPC request (no actual calling supported - just messaging).

xml_rpc(\URLPATH $url, string $method, array $params, boolean $accept_failure = false) : \?string
package core

Parameters

$url

\URLPATH

The XML-RPC call URL

$method

string

The method name to call.

$params

array

An array of parameters.

$accept_failure

boolean

Whether to accept failure.

Returns

\?stringThe result (null: failed).

XML escape the input string.

xmlentities(string $string, integer $quote_style = ENT_COMPAT) : string
package core

Parameters

$string

string

Input string

$quote_style

integer

Quote style

Returns

stringEscaped version of input string

Close a zip file.

zip_close(array $open_zip_file) : boolean
package core

Parameters

$open_zip_file

array

The zip file resource

Returns

booleanWhether the file closed correctly

Closes a directory entry previously opened for reading.

zip_entry_close(array $zip_entry) : boolean
package core

Parameters

$zip_entry

array

Directory entry resource returned by m_zip_read()

Returns

booleanWhether the operation was succesful

Returns the filesize of the directory entry specified in the given entry.

zip_entry_filesize(array $zip_entry) : integer
package core

Parameters

$zip_entry

array

Directory entry resource returned by m_zip_read()

Returns

integerThe file size

Returns the name of the directory entry specified in the given entry.

zip_entry_name(array $zip_entry) : string
package core

Parameters

$zip_entry

array

Directory entry resource returned by m_zip_read()

Returns

stringThe entry name

Opens a directory entry in a zip file for reading.

zip_entry_open(array $zip, array $zip_entry, string $mode = 'rb') : boolean
package core
set rb

Parameters

$zip

array

The zip file resource

$zip_entry

array

Directory entry resource returned by m_zip_read()

$mode

string

The file access mode

Returns

booleanWhether the operation was succesful

Returns the file data of the directory entry specified in the given entry.

zip_entry_read(array $zip_entry, integer $zip_entry_file_size = 1024) : \~string
package core

Parameters

$zip_entry

array

Directory entry resource returned by m_zip_read()

$zip_entry_file_size

integer

The maximum returned data size

Returns

\~stringThe data (false: failure)

Terminate with an error caused by unzipping.

zip_error(integer $errno, boolean $mzip = false) : \Tempcode
package core

Parameters

$errno

integer

The zip error number.

$mzip

boolean

Whether mzip was used.

Returns

\TempcodeError message.

Open a zip file for reading.

zip_open(\PATH $zip_file) : mixed
package core

Parameters

$zip_file

\PATH

The zip file path

Returns

mixedThe zip file resource (number if error)

Reads the next entry in a zip file archive.

zip_read(array $open_zip_file) : \~array
package core

Parameters

$open_zip_file

array

The zip file resource

Returns

\~arrayA directory entry resource for later use with the m_zip_entry_...() functions (false: if there's no more entries to read).

Find file meta information for adding to a zip file

zip_scan_folder(\PATH $path, \PATH $subpath = '') : array
package core

Parameters

$path

\PATH

The full path to the folder to add

$subpath

\PATH

The subpath relative to the path (should be left as the default '', as this is used for the recursion to distinguish the adding base path from where it's currently looking)

Returns

arrayA list of maps that stores time,full_path,name, for each file

Consider virtual zone merging, where paths are not necessarily where you'd expect for pages in zones.

zone_black_magic_filterer(\PATH $path, boolean $relative = false) : \PATH
package core

Parameters

$path

\PATH

The path, assuming in the obvious place.

$relative

boolean

Where the passed path is relative.

Returns

\PATHThe fixed path.

Classes, interfaces, and traits

CMSException

A Composr exception.

« More »

CMS_RSS

RSS loader.

« More »

CMS_simple_xml_reader

Simple XML reader.

« More »

DatabaseConnector

Database handling.

« More »

DecisionTree

Provide multi-screen (multi-form) decision trees.

« More »

Field_restriction_loader

Field restriction loader.

« More »

Forum_driver_base

Forum driver class.

« More »

Hook_sitemap_base

Sitemap node type base class.

« More »

Hook_sitemap_content

Sitemap node type for content types.

« More »

Persistent_caching_apccache

Cache driver class.

« More »

Persistent_caching_eacceleratorcache

Cache driver class.

« More »

Persistent_caching_filecache

Cache driver class.

« More »

Persistent_caching_memcache

Cache driver class.

« More »

Persistent_caching_memcached

Cache driver class.

« More »

Persistent_caching_wincache

Cache driver class.

« More »

Persistent_caching_xcache

Cache driver class.

« More »

Self_learning_cache

The self-learning cache is an adaptive per-page/script cache, which loads from disk in a single efficient operation.

« More »

Standard_crud_module

CRUD module (Create/Update/Delete), for operations on content types.

« More »

Stemmer_EN

PHP5 Implementation of the Porter Stemmer algorithm. Certain elements were borrowed from the (broken) implementation by Jon Abernathy.

« More »

Tempcode

Tempcode (compiled implementation).

« More »

Constants

 

ANTISPAM_RESPONSE_ACTIVE

ANTISPAM_RESPONSE_ACTIVE = 2 
package core
 

ANTISPAM_RESPONSE_ACTIVE_UNKNOWN_STALE

ANTISPAM_RESPONSE_ACTIVE_UNKNOWN_STALE = 3 
package core
 

ANTISPAM_RESPONSE_ERROR

ANTISPAM_RESPONSE_ERROR = -1 
package core
 

ANTISPAM_RESPONSE_SKIP

ANTISPAM_RESPONSE_SKIP = -2 
package core
 

ANTISPAM_RESPONSE_STALE

ANTISPAM_RESPONSE_STALE = 1 
package core
 

ANTISPAM_RESPONSE_UNLISTED

ANTISPAM_RESPONSE_UNLISTED = 0 
package core
 

A_DAILY_EMAIL_DIGEST

A_DAILY_EMAIL_DIGEST = 4 
package core
 

A_INSTANT_EMAIL

A_INSTANT_EMAIL = 2 
package core
 

A_INSTANT_PT

A_INSTANT_PT = 64 
package core
 

A_INSTANT_SMS

A_INSTANT_SMS = 32 
package core
 

A_MONTHLY_EMAIL_DIGEST

A_MONTHLY_EMAIL_DIGEST = 16 
package core
 

A_NA

A_NA = 0 
package core
 

A_WEB_NOTIFICATION

A_WEB_NOTIFICATION = 128 
package core
 

A_WEEKLY_EMAIL_DIGEST

A_WEEKLY_EMAIL_DIGEST = 8 
package core
 

A__ALL

A__ALL = 16777215 
package core
 

A__CHOICE

A__CHOICE = -2 
package core
 

A__STATISTICAL

A__STATISTICAL = -1 
package core
 

BREADCRUMB_CROP_LENGTH

BREADCRUMB_CROP_LENGTH = intval($bcl) 
package core
 

CACHE_AGAINST_BOT_STATUS

CACHE_AGAINST_BOT_STATUS = 8 
package core
 

CACHE_AGAINST_DEFAULT

CACHE_AGAINST_DEFAULT = CACHE_AGAINST_BOT_STATUS | CACHE_AGAINST_TIMEZONE 
package core
 

CACHE_AGAINST_MEMBER

CACHE_AGAINST_MEMBER = 2 
package core
 

CACHE_AGAINST_NOTHING_SPECIAL

CACHE_AGAINST_NOTHING_SPECIAL = 0 
package core
 

CACHE_AGAINST_PERMISSIVE_GROUPS

CACHE_AGAINST_PERMISSIVE_GROUPS = 4 
package core
 

CACHE_AGAINST_STAFF_STATUS

CACHE_AGAINST_STAFF_STATUS = 1 
package core
 

CACHE_AGAINST_TIMEZONE

CACHE_AGAINST_TIMEZONE = 16 
package core
 

CC_ESCAPED

CC_ESCAPED = 5 
package core
 

CMS_UPLOAD_ANYTHING

CMS_UPLOAD_ANYTHING = 15 
package core
 

CMS_UPLOAD_AUDIO

CMS_UPLOAD_AUDIO = 4 
package core
 

CMS_UPLOAD_IMAGE

CMS_UPLOAD_IMAGE = 1 
package core
 

CMS_UPLOAD_SWF

CMS_UPLOAD_SWF = 8 
package core
 

CMS_UPLOAD_VIDEO

CMS_UPLOAD_VIDEO = 2 
package core
 

COMCODE_EDIT_ANY

COMCODE_EDIT_ANY = 2 
package core
 

COMCODE_EDIT_NONE

COMCODE_EDIT_NONE = 0 
package core
 

COMCODE_EDIT_OWN

COMCODE_EDIT_OWN = 1 
package core
 

CSL_PERMISSION_ADD

CSL_PERMISSION_ADD = 1 
package core
 

CSL_PERMISSION_DELETE

CSL_PERMISSION_DELETE = 4 
package core
 

CSL_PERMISSION_EDIT

CSL_PERMISSION_EDIT = 2 
package core
 

CSL_PERMISSION_VIEW

CSL_PERMISSION_VIEW = 0 
package core
 

CSS_ESCAPED

CSS_ESCAPED = 13 
package core
 

DB_MAX_FIELD_IDENTIFIER_SIZE

DB_MAX_FIELD_IDENTIFIER_SIZE = 31 
package core
 

DB_MAX_IDENTIFIER_SIZE

DB_MAX_IDENTIFIER_SIZE = 32 
package core
 

DB_MAX_KEY_SIZE

DB_MAX_KEY_SIZE = 500 
package core
 

DB_MAX_KEY_SIZE_UNICODE

DB_MAX_KEY_SIZE_UNICODE = 1000 
package core
 

DB_MAX_PRIMARY_KEY_SIZE

DB_MAX_PRIMARY_KEY_SIZE = 251 
package core
 

DB_MAX_ROW_SIZE

DB_MAX_ROW_SIZE = 8000 
package core
 

DB_MAX_ROW_SIZE_UNICODE

DB_MAX_ROW_SIZE_UNICODE = 24000 
package core
 

DQ_ESCAPED

DQ_ESCAPED = 3 
package core
 

ENTITY_ESCAPED

ENTITY_ESCAPED = 1 
package core
 

E_RECOVERABLE_ERROR

E_RECOVERABLE_ERROR = 4096 
package core
 

FIND_ALL_PAGES__ALL

FIND_ALL_PAGES__ALL = 2 
package core
 

FIND_ALL_PAGES__NEWEST

FIND_ALL_PAGES__NEWEST = 1 
package core
 

FIND_ALL_PAGES__PERFORMANT

FIND_ALL_PAGES__PERFORMANT = 0 
package core
 

FORCIBLY_ENTITY_ESCAPED

FORCIBLY_ENTITY_ESCAPED = 12 
package core
 

GOOGLE_APPENGINE

GOOGLE_APPENGINE = isset($_SERVER['APPLICATION_ID']) 
package core
 

HHVM

HHVM = strpos(PHP_VERSION, 'hiphop') !== false 
package core
 

ID_ESCAPED

ID_ESCAPED = 9 
package core
 

IGNORE_ACCESS_CONTROLLERS

IGNORE_ACCESS_CONTROLLERS = 1 
package core
 

IGNORE_BUNDLED_UNSHIPPED_VOLATILE

IGNORE_BUNDLED_UNSHIPPED_VOLATILE = 2048 
package core
 

IGNORE_BUNDLED_VOLATILE

IGNORE_BUNDLED_VOLATILE = 1024 
package core
 

IGNORE_CUSTOM_DIR_CONTENTS

IGNORE_CUSTOM_DIR_CONTENTS = 2 
package core
 

IGNORE_CUSTOM_THEMES

IGNORE_CUSTOM_THEMES = 64 
package core
 

IGNORE_CUSTOM_ZONES

IGNORE_CUSTOM_ZONES = 32 
package core
 

IGNORE_DEFAULTS

IGNORE_DEFAULTS = 0 
package core
 

IGNORE_EDITFROM_FILES

IGNORE_EDITFROM_FILES = 8 
package core
 

IGNORE_HIDDEN_FILES

IGNORE_HIDDEN_FILES = 4 
package core
 

IGNORE_NONBUNDLED_SCATTERED

IGNORE_NONBUNDLED_SCATTERED = 512 
package core
 

IGNORE_NON_EN_SCATTERED_LANGS

IGNORE_NON_EN_SCATTERED_LANGS = 4096 
package core
 

IGNORE_NON_REGISTERED

IGNORE_NON_REGISTERED = 128 
package core
 

IGNORE_REVISION_FILES

IGNORE_REVISION_FILES = 16 
package core
 

IGNORE_UPLOADS

IGNORE_UPLOADS = 8192 
package core
 

IGNORE_USER_CUSTOMISE

IGNORE_USER_CUSTOMISE = 256 
package core
 

INTEGER_MAGIC_NULL

INTEGER_MAGIC_NULL = 1634817353 
package core
 

I_UNDERSTAND_PATH_INJECTION

I_UNDERSTAND_PATH_INJECTION = 4 
package core
 

I_UNDERSTAND_SQL_INJECTION

I_UNDERSTAND_SQL_INJECTION = 1 
package core
 

I_UNDERSTAND_XSS

I_UNDERSTAND_XSS = 2 
package core
 

JSHTML_ESCAPED

JSHTML_ESCAPED = 7 
package core
 

MAXIMUM_RESULT_COUNT_POINT

MAXIMUM_RESULT_COUNT_POINT = intval($maximum_result_count_point) 
package core
 

MAX_STACK_TRACE_VALUE_LENGTH

MAX_STACK_TRACE_VALUE_LENGTH = 300 
package core
       

NAUGHTY_ESCAPED

NAUGHTY_ESCAPED = 10 
package core
 

NL2_ESCAPED

NL2_ESCAPED = 8 
package core
 

NL_ESCAPED

NL_ESCAPED = 4 
package core
 

NULL_ESCAPED

NULL_ESCAPED = 11 
package core
 

PARSE_DIRECTIVE

PARSE_DIRECTIVE = 1 
package core
 

PARSE_DIRECTIVE_INNER

PARSE_DIRECTIVE_INNER = 5 
package core
 

PARSE_LANGUAGE_REFERENCE

PARSE_LANGUAGE_REFERENCE = 3 
package core
 

PARSE_NO_MANS_LAND

PARSE_NO_MANS_LAND = 0 
package core
 

PARSE_PARAMETER

PARSE_PARAMETER = 4 
package core
 

PARSE_SYMBOL

PARSE_SYMBOL = 2 
package core
 

PASSWORD_BCRYPT

PASSWORD_BCRYPT = 1 
package core
 

PASSWORD_DEFAULT

PASSWORD_DEFAULT = PASSWORD_BCRYPT 
package core
 

PASSWORD_SALT

PASSWORD_SALT = 1 
package core
 

PURE_STRING

PURE_STRING = 16 
package core
 

SALT_MD5PASSWORD

SALT_MD5PASSWORD = 0 
package core
 

SELF_REDIRECT

SELF_REDIRECT = '!--:)defUNLIKELY' 
package core
 

SITEMAP_GATHER_AUTHOR

SITEMAP_GATHER_AUTHOR = 16 
package core
 

SITEMAP_GATHER_CATEGORIES

SITEMAP_GATHER_CATEGORIES = 512 
package core
 

SITEMAP_GATHER_DB_ROW

SITEMAP_GATHER_DB_ROW = 2048 
package core
 

SITEMAP_GATHER_DESCRIPTION

SITEMAP_GATHER_DESCRIPTION = 1 
package core
 

SITEMAP_GATHER_IMAGE

SITEMAP_GATHER_IMAGE = 2 
package core
 

SITEMAP_GATHER_META

SITEMAP_GATHER_META = 256 
package core
 

SITEMAP_GATHER_NUM_COMMENTS

SITEMAP_GATHER_NUM_COMMENTS = 128 
package core
 

SITEMAP_GATHER_RATING

SITEMAP_GATHER_RATING = 64 
package core
 

SITEMAP_GATHER_SUBMITTER

SITEMAP_GATHER_SUBMITTER = 8 
package core
 

SITEMAP_GATHER_TIMES

SITEMAP_GATHER_TIMES = 4 
package core
 

SITEMAP_GATHER_VALIDATED

SITEMAP_GATHER_VALIDATED = 1024 
package core
 

SITEMAP_GATHER_VIEWS

SITEMAP_GATHER_VIEWS = 32 
package core
 

SITEMAP_GATHER__ALL

SITEMAP_GATHER__ALL = 268435455 
package core
 

SITEMAP_GEN_COLLAPSE_ZONES

SITEMAP_GEN_COLLAPSE_ZONES = 128 
package core
 

SITEMAP_GEN_CONSIDER_SECONDARY_CATEGORIES

SITEMAP_GEN_CONSIDER_SECONDARY_CATEGORIES = 4 
package core
 

SITEMAP_GEN_CONSIDER_VALIDATION

SITEMAP_GEN_CONSIDER_VALIDATION = 8 
package core
 

SITEMAP_GEN_KEEP_FULL_STRUCTURE

SITEMAP_GEN_KEEP_FULL_STRUCTURE = 64 
package core
 

SITEMAP_GEN_LABEL_CONTENT_TYPES

SITEMAP_GEN_LABEL_CONTENT_TYPES = 16 
package core
 

SITEMAP_GEN_NONE

SITEMAP_GEN_NONE = 0 
package core
   

SITEMAP_GEN_REQUIRE_PERMISSION_SUPPORT

SITEMAP_GEN_REQUIRE_PERMISSION_SUPPORT = 1 
package core
 

SITEMAP_GEN_USE_PAGE_GROUPINGS

SITEMAP_GEN_USE_PAGE_GROUPINGS = 2 
package core
 

SITEMAP_IMPORTANCE_HIGH

SITEMAP_IMPORTANCE_HIGH = 0.8 
package core
 

SITEMAP_IMPORTANCE_LOW

SITEMAP_IMPORTANCE_LOW = 0.2 
package core
 

SITEMAP_IMPORTANCE_MEDIUM

SITEMAP_IMPORTANCE_MEDIUM = 0.5 
package core
 

SITEMAP_IMPORTANCE_NONE

SITEMAP_IMPORTANCE_NONE = 0.0 
package core
 

SITEMAP_IMPORTANCE_ULTRA

SITEMAP_IMPORTANCE_ULTRA = 1.0 
package core
 

SITEMAP_MAX_ROWS_PER_LOOP

SITEMAP_MAX_ROWS_PER_LOOP = 500 
package core
 

SITEMAP_NODE_HANDLED

SITEMAP_NODE_HANDLED = 1 
package core
 

SITEMAP_NODE_HANDLED_VIRTUALLY

SITEMAP_NODE_HANDLED_VIRTUALLY = 2 
package core
 

SITEMAP_NODE_NOT_HANDLED

SITEMAP_NODE_NOT_HANDLED = 0 
package core
 

SQ_ESCAPED

SQ_ESCAPED = 2 
package core
 

STATIC_CACHE__FAILOVER_MODE

STATIC_CACHE__FAILOVER_MODE = 4 
package core
 

STATIC_CACHE__FAILOVER_MODE

STATIC_CACHE__FAILOVER_MODE = 4 
package core
 

STATIC_CACHE__FAST_SPIDER

STATIC_CACHE__FAST_SPIDER = 1 
package core
 

STATIC_CACHE__FAST_SPIDER

STATIC_CACHE__FAST_SPIDER = 1 
package core
 

STATIC_CACHE__GUEST

STATIC_CACHE__GUEST = 2 
package core
 

STATIC_CACHE__GUEST

STATIC_CACHE__GUEST = 2 
package core
 

STRING_MAGIC_NULL

STRING_MAGIC_NULL = '!--:)abcUNLIKELY' 
package core
 

TC_DIRECTIVE

TC_DIRECTIVE = 4 
package core
 

TC_KNOWN

TC_KNOWN = 1 
package core
 

TC_LANGUAGE_REFERENCE

TC_LANGUAGE_REFERENCE = 2 
package core
 

TC_PARAMETER

TC_PARAMETER = 3 
package core
 

TC_SYMBOL

TC_SYMBOL = 0 
package core
 

TEMPCODE_VARIABLE_ESCAPED

TEMPCODE_VARIABLE_ESCAPED = 15 
package core
 

UL2_ESCAPED

UL2_ESCAPED = 14 
package core
 

UL_ESCAPED

UL_ESCAPED = 6 
package core
 

UNZIP_CMD

UNZIP_CMD = get_option('unzip_cmd') 
package core
 

UNZIP_DIR

UNZIP_DIR = $ud 
package core
 

UPLOAD_PRECEDENCE_HIGH

UPLOAD_PRECEDENCE_HIGH = 10 
package core
 

UPLOAD_PRECEDENCE_LOW

UPLOAD_PRECEDENCE_LOW = 1 
package core
 

UPLOAD_PRECEDENCE_MEDIUM

UPLOAD_PRECEDENCE_MEDIUM = 5 
package core
 

UPLOAD_PRECEDENCE_NO

UPLOAD_PRECEDENCE_NO = 0 
package core
 

UPLOAD_PRECEDENCE_REGARDLESS

UPLOAD_PRECEDENCE_REGARDLESS = 1000 
package core
 

URLS_PER_SITEMAP_SET

URLS_PER_SITEMAP_SET = 250 
package core