<?php /*

 Composr
 Copyright (c) Christopher Graham, 2004-2024

 See docs/LICENSE.md for full licensing information.


 NOTE TO PROGRAMMERS:
   Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
   **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****

*/

/**
 * @license    http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
 * @copyright  Christopher Graham
 * @package    core
 */

//debug_print_backtrace();exit();

// The symbols defined in this file are not used on most page loads. They are separated out for performance.

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_MAKE_URL_ABSOLUTE(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (!empty($param[0])) {
        $value = $param[0];
        if (url_is_local($value)) {
            $value = get_custom_base_url() . '/' . $value;
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_MAILTO(string $lang, array $escaped, array $param) : string
{
    require_code('crypt');

    $value = mailto_obfuscated();

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_SUBTRACT(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[1])) && (is_numeric($param[0])) && (is_numeric($param[1]))) {
        $_value = 0.0;

        foreach ($param as $i => $p) {
            $_p = floatval(str_replace(',', '', $p));
            if ($i == 0) {
                $_value = $_p;
            } else {
                $_value -= $_p;
            }
        }

        $value = float_to_raw_string($_value, 20, true);
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ALREADY_RATED(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('feedback');
        $previous_ratings = null;

        $already_rated = already_rated([$param[0]], $param[1], $previous_ratings);

        if (empty($param[2])) {
            $value = ($already_rated ? '1' : '0');
        } else {
            $value = strval(array_shift($previous_ratings));
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ANCHOR(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!@cms_empty_safe($param[0])) {
        $_value = do_template('ANCHOR', ['_GUID' => '8795c70c9dd7c6217bb765264ac24092', 'NAME' => $param[0]]);
        $value = $_value->evaluate();
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_AT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[1])) && (is_numeric($param[1]))) {
        $value = cms_mb_substr($param[0], intval($param[1]), 1);
    }

    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
        ocp_mark_as_escaped($value);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ATTACHMENT_DOWNLOADS(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        $db = $GLOBALS['SITE_DB'];
        if ((!empty($param[1])) && (get_forum_type() == 'cns')) {
            $db = $GLOBALS['FORUM_DB'];
        }
        $_value = $db->query_select_value_if_there('attachments', 'a_num_downloads', ['id' => intval($param[0])]);
        $value = ($_value === null) ? '?' : strval($_value);
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_POINTS_BALANCE(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (addon_installed('points')) {
        require_code('points');
        $value = strval(points_balance(((isset($param[0])) && (is_numeric($param[0]))) ? intval($param[0]) : get_member()));
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_AWARD_ID(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        static $awarded_content_ids = [];
        if (!isset($awarded_content_ids[intval($param[0])])) {
            $test = $GLOBALS['SITE_DB']->query_select('award_archive', ['content_id', 'date_and_time'], ['a_type_id' => intval($param[0])], 'ORDER BY date_and_time DESC', 1);
            $awarded_content_ids[intval($param[0])] = array_key_exists(0, $test) ? $test[0]['content_id'] : null;
        }
        $value = isset($awarded_content_ids[intval($param[0])]) ? $awarded_content_ids[intval($param[0])] : '';
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_CAN_SPELLCHECK(string $lang, array $escaped, array $param) : string
{
    $value = (function_exists('pspell_check') || function_exists('enchant_dict_check')) ? '1' : '0';

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_URLDECODE(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (isset($param[0])) {
        $value = urldecode($param[0]);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_CLEAN_FILE_SIZE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        require_code('files');
        $value = clean_file_size(intval($param[0]));
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMCODE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        push_lax_comcode(true);
        $_value = comcode_to_tempcode($param[0], null, !isset($param[1]) || $param[1] == '1');
        pop_lax_comcode();
        $value = $_value->evaluate();
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_FROM_BREADCRUMBS(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $separator = do_template('BREADCRUMB_SEPARATOR', ['_GUID' => 'y28e21cdbc38a3037d083f619bb311ae',]);
        $value = '=' . str_replace($separator->evaluate(), ',=', str_replace(',', '\,', $param[0]));
        if ((!isset($param[1])) || ($param[1] == '0')) {
            $value = strip_tags($value);
        } else {
            $value = strip_tags($value, '<a>');
        }
        $value = trim($value);
        if (($GLOBALS['XSS_DETECT']) && (ocp_is_escaped($param[0]))) {
            ocp_mark_as_escaped($value);
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_NICIFY(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $map = comma_list_str_to_arr($param[0]);
        $value = '';
        foreach ($map as $val) {
            if ($value != '') {
                $value .= ', ';
            }
            $value .= html_entity_decode($val, ENT_QUOTES);
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_POP(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $map = comma_list_str_to_arr($param[0]);
        array_pop($map);
        $value = comma_list_arr_to_str($map);
        if (($GLOBALS['XSS_DETECT']) && (ocp_is_escaped($param[0]))) {
            ocp_mark_as_escaped($value);
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_PUSH(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[1])) {
        $map = comma_list_str_to_arr($param[0]);
        array_push($map, $param[1]);
        $value = comma_list_arr_to_str($map);
        if (($GLOBALS['XSS_DETECT']) && (ocp_is_escaped($param[0]))) {
            ocp_mark_as_escaped($value);
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_SHIFT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $map = comma_list_str_to_arr($param[0]);
        array_shift($map);
        $value = comma_list_arr_to_str($map);
        if (($GLOBALS['XSS_DETECT']) && (ocp_is_escaped($param[0]))) {
            ocp_mark_as_escaped($value);
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_UNSHIFT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[1])) {
        $map = comma_list_str_to_arr($param[0]);
        array_unshift($map, $param[1]);
        $value = comma_list_arr_to_str($map);
        if (($GLOBALS['XSS_DETECT']) && (ocp_is_escaped($param[0]))) {
            ocp_mark_as_escaped($value);
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_REVERSE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $map = comma_list_str_to_arr($param[0]);
        $map = array_reverse($map);
        $value = comma_list_arr_to_str($map);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_COMMA_LIST_SET(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[2])) {
        require_code('blocks');
        $values = comma_list_str_to_arr($param[0]);
        $values[$param[1]] = $param[2];
        $value = comma_list_arr_to_str($values);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_PARENTAL_CONSENT_REQUIRED(string $lang, array $escaped, array $param) : string
{
    $value = ((get_option('is_on_parental_consent') == '1') && (get_option('dobs') == '1')) ? '1' : '0';

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_CSS_DIMENSION_REDUCE(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[1])) && (is_numeric($param[1]))) {
        $value = $param[0];
        if (substr($value, -2) == 'px') {
            $b = $param[1];
            $value = strval(intval(substr($value, 0, -2)) - intval($b)) . 'px';
        }
        if ($value == '') {
            $value = '0px';
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_CURRENTLY_INVISIBLE(string $lang, array $escaped, array $param) : string
{
    $value = is_invisible() ? '1' : '0';

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_DEC(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (isset($param[0])) {
        global $TEMPCODE_SETGET;
        if (!isset($TEMPCODE_SETGET[$param[0]])) {
            $TEMPCODE_SETGET[$param[0]] = '0';
        }
        $TEMPCODE_SETGET[$param[0]] = strval(intval($TEMPCODE_SETGET[$param[0]]) - 1);
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_DIV_CEIL(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[1])) && (is_numeric($param[0])) && (is_numeric($param[1]))) {
        $value = strval(intval(ceil(floatval($param[0]) / floatval($param[1]))));
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ENTITY_DECODE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        static $charset = null;
        if ($charset === null) {
            $charset = get_charset();
        }
        $value = @html_entity_decode($param[0], ENT_QUOTES, $charset);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ESCAPE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $d_escaping = [(!empty($param[1])) ? @constant($param[1]) : ENTITY_ESCAPED];
        if ($d_escaping[0] === null) {
            attach_message(do_lang('_UNKNOWN') . ': ' . $param[1], 'warn');
        } else {
            for ($i = 0; $i < max(1, ((isset($param[2])) && (is_numeric($param[2]))) ? intval($param[2]) : 1); $i++) {
                if (is_string($param[0])) {
                    apply_tempcode_escaping($d_escaping, $param[0]);
                }
            }
        }
        $value = $param[0];
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_GUID_VIA_ID(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!addon_installed('commandr')) {
        return $value;
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('resource_fs');
        $value = find_guid_via_id($param[0], $param[1]);
        if ($value === null) {
            $value = '';
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_ID_VIA_GUID(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!addon_installed('commandr')) {
        return $value;
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('resource_fs');
        $value = find_id_via_guid($param[0]);
        if ($value === null) {
            $value = '';
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_ID_VIA_LABEL(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!addon_installed('commandr')) {
        return $value;
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('resource_fs');
        $value = find_id_via_label($param[0], $param[1], (!empty($param[2])) ? $param[2] : null);
        if ($value === null) {
            $value = '';
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_ID_VIA_COMMANDR_FS_FILENAME(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!addon_installed('commandr')) {
        return $value;
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('resource_fs');
        $value = find_id_via_commandr_fs_filename($param[0], $param[1]);
        if ($value === null) {
            $value = '';
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_ID_VIA_URL_MONIKER(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('urls2');
        $value = find_id_via_url_moniker($param[0], $param[1]);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_LABEL_VIA_ID(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!addon_installed('commandr')) {
        return $value;
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('resource_fs');
        $value = find_label_via_id($param[0], $param[1]);
        if ($value === null) {
            $value = '';
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_COMMANDR_FS_FILENAME_VIA_ID(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!addon_installed('commandr')) {
        return $value;
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        require_code('resource_fs');
        $value = find_commandr_fs_filename_via_id($param[0], $param[1]);
        if ($value === null) {
            $value = '';
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FIND_URL_MONIKER_VIA_ID(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((!@cms_empty_safe($param[0])) && (!@cms_empty_safe($param[1]))) {
        $value = find_id_moniker(['page' => $param[0], 'type' => $param[1], 'id' => $param[1]], isset($param[2]) ? $param[2] : '');
        if ($value === null) {
            $value = '';
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FLOAT_FORMAT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        $value = float_format(floatval($param[0]), ((isset($param[1])) && (is_numeric($param[1]))) ? intval($param[1]) : 2, !empty($param[2]));
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FORUM_CONTEXT(string $lang, array $escaped, array $param) : string
{
    global $SET_CONTEXT_FORUM;
    $value = ($SET_CONTEXT_FORUM === null) ? '' : strval($SET_CONTEXT_FORUM);

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_GEOLOCATE(string $lang, array $escaped, array $param) : string
{
    require_code('locations');

    $value = geolocate_ip((!empty($param[0])) ? $param[0] : null);

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_GROUP_NAME(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(((isset($param[1])) && (is_numeric($param[1]))) ? intval($param[1]) : get_member());
    $i = ((isset($param[0])) && (is_numeric($param[0]))) ? intval($param[0]) : 0;
    if (isset($groups[$i])) {
        $all_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
        $value = $all_usergroups[$groups[$i]];
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_HAS_CATEGORY_ACCESS(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((!empty($param[0])) && (function_exists('has_category_access'))) {
        $value = has_category_access(((isset($param[2])) && (is_numeric($param[2]))) ? intval($param[2]) : get_member(), $param[0], $param[1]) ? '1' : '0';
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_SUPPORTS_FRACTIONAL_EDITABLE(string $lang, array $escaped, array $param) : string
{
    $value = '0';
    if (!empty($param[0])) {
        $edit_pagelink = $param[0];
        $has_permission = ((!empty($param[1])) ? $param[1] : null) === '1';

        list($zone, $attributes,) = page_link_decode($edit_pagelink);
        if ($zone == '_SEARCH') {
            $zone = get_module_zone($attributes['page']);
        }
        if ((has_actual_page_access(get_member(), $attributes['page'], $zone)) && (($has_permission === true) || (($has_permission === null) && (has_zone_access(get_member(), 'adminzone'))))) {
            $value = '1';
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_HAS_PAGE_ACCESS(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((!empty($param[0])) && (function_exists('has_page_access'))) {
        if (!isset($param[1])) {
            $param[1] = '_SEARCH';
        }

        $value = has_page_access(((isset($param[2])) && (is_numeric($param[2]))) ? intval($param[2]) : get_member(), $param[0], $param[1], !empty($param[3])) ? '1' : '0';
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_HAS_SUBMIT_PERMISSION(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (!empty($param[0])) {
        $range = cms_strtolower_ascii($param[0]);
        $ip_address = $param[1];
        $member_id = ((isset($param[2])) && (is_numeric($param[2]))) ? intval($param[2]) : get_member();
        $cms_page = (!@cms_empty_safe($param[3])) ? $param[3] : get_page_name();
        if (isset($param[6])) {
            $value = has_submit_permission($range, $member_id, $ip_address, $cms_page, [$param[5], $param[6]]) ? '1' : '0';
        } else {
            $value = has_submit_permission($range, $member_id, $ip_address, $cms_page) ? '1' : '0';
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ISSET(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (!empty($param[0])) {
        global $TEMPCODE_SETGET;
        $value = (isset($TEMPCODE_SETGET[$param[0]])) ? '1' : '0';
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_IS_FRIEND(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        if (addon_installed('chat')) {
            require_code('chat');
            $test = member_befriended(intval($param[0]), ((isset($param[1])) && (is_numeric($param[1]))) ? intval($param[1]) : get_member());
            $value = ($test ? '0' : '1');
        } else {
            $value = '0';
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_IS_VIRTUALISED_REQUEST(string $lang, array $escaped, array $param) : string
{
    $value = $GLOBALS['IS_VIRTUALISED_REQUEST'] ? '1' : '0';

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_MEMBER_OVERRIDE(string $lang, array $escaped, array $param) : string
{
    $value = strval(get_member());

    if ((get_page_name() == 'members') && (get_param_string('type', 'browse') == 'view')) {
        $user = get_param_string('id', '');
        if (is_string($user)) {
            $member_id_of = $GLOBALS['FORUM_DRIVER']->get_member_from_username($user);
            if ($member_id_of !== null) {
                $value = strval($member_id_of);
            }
        } else {
            $value = $user;
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_MOD(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        $value = strval(max(intval($param[0]), -intval($param[0])));
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_MULT(string $lang, array $escaped, array $param) : string
{
    $_value = 1.0;

    foreach ($param as $p) {
        $_value *= floatval(str_replace(',', '', $p));
    }

    $value = float_to_raw_string($_value, 20, true);

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_NEGATE(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        $value = strval(-intval($param[0]));
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_MEMBER_DATA(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((get_forum_type() == 'cns') && (!@cms_empty_safe($param[0]))) {
        require_code('cns_general');
        $member_id = ((isset($param[1])) && (is_numeric($param[1]))) ? intval($param[1]) : get_member();
        $setting = $param[0];
        $member_info = cns_read_in_member_profile($member_id, [$setting]);
        if (isset($member_info[$setting])) {
            $_value = $member_info[$setting];

            if (is_bool($_value)) {
                $value = ($_value ? '1' : '0');
            }

            if (is_integer($_value)) {
                $_value = strval($_value);
            }

            if (is_float($_value)) {
                $_value = float_to_raw_string($_value);
            }
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_NUM_RATINGS(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((!empty($param[0])) && (!@cms_empty_safe($param[1]))) {
        global $DISPLAYED_TITLE;

        static $cache_num_ratings = [];
        $cache_key = serialize($param);
        if (isset($cache_num_ratings[$cache_key])) {
            $value = $cache_num_ratings[$cache_key];
        } else {
            require_code('feedback');
            $rating = get_rating_simple_array(empty($param[3]) ? get_self_url(true) : $param[3], @cms_empty_safe($param[4]) ? (($DISPLAYED_TITLE === null) ? '' : $DISPLAYED_TITLE->evaluate()) : $param[4], $param[0], $param[1], empty($param[5]) ? 'RATING_FORM' : $param[5], empty($param[2]) ? null : $param[2]);
            if ($rating !== null) {
                $value = $rating['ALL_RATING_CRITERIA'][key($rating['ALL_RATING_CRITERIA'])]['NUM_RATINGS'];
            }

            $cache_num_ratings[$cache_key] = $value;
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_OBFUSCATE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        require_code('crypt');
        $value = obfuscate_entities($param[0]);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_CNS_MEMBER_HTML(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (get_forum_type() == 'cns') {
        require_code('cns_members');
        require_code('cns_members2');
        $_value = render_member_box(((isset($param[0])) && (is_numeric($param[0]))) ? intval($param[0]) : get_member(), false, true, [], false);
        $value = $_value->evaluate();
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_PAD_LEFT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[1])) && (is_numeric($param[1]))) {
        $value = str_pad($param[0], intval($param[1]), (isset($param[2])) ? $param[2] : ' ', STR_PAD_LEFT);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_PAD_RIGHT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[1])) && (is_numeric($param[1]))) {
        $value = str_pad($param[0], intval($param[1]), (isset($param[2])) ? $param[2] : ' ', STR_PAD_RIGHT);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_POINTS_SPENT(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (addon_installed('points')) {
        require_code('points');
        $value = strval(points_used(((isset($param[0])) && (is_numeric($param[0]))) ? intval($param[0]) : get_member()));
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_QUERY_STRING(string $lang, array $escaped, array $param) : string
{
    $value = $_SERVER['QUERY_STRING'];

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_REM(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((isset($param[0])) && (is_numeric($param[0])) && (!empty($param[1]))) {
        $value = strval(intval($param[0]) % intval($param[1]));
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_RESET_CYCLE(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (isset($param[0])) {
        global $CYCLES;
        $CYCLES[$param[0]] = 0;
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_SECONDS_PERIOD(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        $value = display_seconds_period(intval($param[0]));
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_SET_TITLE(string $lang, array $escaped, array $param) : string
{
    if (isset($param[0])) {
        global $SHORT_TITLE, $FORCE_SET_TITLE;
        $SHORT_TITLE = $param[0];
        $FORCE_SET_TITLE = true;
    }

    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_SITE_SCOPE(string $lang, array $escaped, array $param) : string
{
    $value = get_option('site_scope');

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_STAFF_ADDRESS(string $lang, array $escaped, array $param) : string
{
    require_code('crypt');
    $value = obfuscate_email_address(get_option('staff_address'));

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_STAFF_ADDRESS_PURE(string $lang, array $escaped, array $param) : string
{
    $value = get_option('staff_address');

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_STRPOS(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (!@cms_empty_safe($param[1])) {
        $t_value = strpos($param[0], $param[1]);
        $value = ($t_value === false) ? '0' : strval($t_value);
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_STARTS_WITH(string $lang, array $escaped, array $param) : string
{
    $value = '1';

    if (!@cms_empty_safe($param[1])) {
        $value = (substr($param[0], 0, strlen($param[1])) === $param[1]) ? '1' : '0';
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ENDS_WITH(string $lang, array $escaped, array $param) : string
{
    $value = '1';

    if (!@cms_empty_safe($param[1])) {
        $value = (substr($param[0], -strlen($param[1])) === $param[1]) ? '1' : '0';
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_TEMPCODE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        require_code('tempcode_compiler');
        $_value = template_to_tempcode($param[0]);
        $value = $_value->evaluate();
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_MATURITY_FILTER_REQUESTED(string $lang, array $escaped, array $param) : string
{
    $safe = '';
    if (function_exists('getallheaders')) {
        $headers = getallheaders();
        if (isset($headers['prefer'])) {
            $safe = $headers['prefer'];
        }
    } elseif (isset($_SERVER['HTTP_PREFER'])) {
        $safe = $_SERVER['HTTP_PREFER'];
    }
    if (cms_strtolower_ascii($safe) == 'safe') {
        return '1';
    }
    return '0';
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_TIME_PERIOD(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[0])) && (is_numeric($param[0]))) {
        $value = display_time_period(intval($param[0]));
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_RANK_POINTS(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (addon_installed('points')) {
        require_code('points');
        $value = strval(points_rank(((isset($param[0])) && (is_numeric($param[0]))) ? intval($param[0]) : get_member()));
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_TO_TIMESTAMP(string $lang, array $escaped, array $param) : string
{
    if (!empty($param[0])) {
        $value = strval(strtotime($param[0]));
        if (!empty($param[1])) {
            $value = strval(usertime_to_utctime(intval($value))); // '1' means date was in user-time so needs converting to a UTC timestamp
        }
    } else {
        $value = strval(time());
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_TRUNCATE_EXPAND(string $lang, array $escaped, array $param) : string
{
    if (isset($param[0])) {
        $len = (!empty($param[1])) ? intval($param[1]) : 60;
        $generate_tooltip = (!empty($param[2]));
        if (@cms_empty_safe($param[3])) {
            $is_html = null;
        } else {
            $is_html = ($param[3] == '1');
        }
        $literal_pos = (!empty($param[4]));
        $grammar_completeness_tolerance = (!empty($param[5])) ? floatval($param[5]) : 0.0;

        $value = generate_truncation($param[0], 'expand', $len, $generate_tooltip, $is_html, $literal_pos, $grammar_completeness_tolerance);
    } else {
        $value = '';
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_TRUNCATE_RIGHT(string $lang, array $escaped, array $param) : string
{
    if (isset($param[0])) {
        $len = (!empty($param[1])) ? intval($param[1]) : 60;
        $generate_tooltip = (!empty($param[2]));
        if (@cms_empty_safe($param[3])) {
            $is_html = null;
        } else {
            $is_html = ($param[3] == '1');
        }
        $literal_pos = (!empty($param[4]));
        $grammar_completeness_tolerance = (!empty($param[5])) ? floatval($param[5]) : 0.0;

        $value = generate_truncation($param[0], 'right', $len, $generate_tooltip, $is_html, $literal_pos, $grammar_completeness_tolerance);
    } else {
        $value = '';
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_WCASE(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $value = cms_mb_ucwords($param[0]);
    }

    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
        ocp_mark_as_escaped($value);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_VIEWS(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if ((!empty($param[0])) && (!empty($param[1])) && (isset($param[2]))) {
        $id_field = /*isset($param[4]) ? $param[4] : */'id'; // Not allowed on fields other than 'id', for security reasons
        if (preg_match('#^\w*views\w*$#', $param[1]) != 0) {
            $test = $GLOBALS['SITE_DB']->query_select_value_if_there($param[0], $param[1], [$id_field => $param[2]]);
            if ($test !== null) {
                $value = integer_format($test);
            }
        }
    }

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_WORDWRAP(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((isset($param[1])) && (is_numeric($param[1]))) {
        $cut = (!empty($param[3]));
        $value = wordwrap($param[0], intval($param[1]), isset($param[2]) ? $param[2] : '<br />', $cut);
    }

    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
        ocp_mark_as_escaped($value);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_XOR(string $lang, array $escaped, array $param) : string
{
    $count = 0;
    foreach ($param as $test) {
        if ($test == '1') {
            $count++;
            if ($count == 2) {
                break;
            }
        }
    }
    $value = ($count == 1) ? '1' : '0';

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_ZONE_HEADER_TEXT(string $lang, array $escaped, array $param) : string
{
    $value = get_translated_text($GLOBALS['ZONE']['zone_header_text']);

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_SELF_PAGE_LINK(string $lang, array $escaped, array $param) : string
{
    $value = '';
    global $IN_SELF_ROUTING_SCRIPT;
    if ($IN_SELF_ROUTING_SCRIPT) {
        $value = get_current_page_link(false);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }

    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_SET_TUTORIAL_LINK(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if ((!empty($param[1])) && ($param[1][0] != '#')) {
        require_code('comcode_renderer');
        set_tutorial_link($param[0], $param[1]);
    }

    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_DISPLAY_CONCEPT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if (!empty($param[0])) {
        $key = $param[0];
        require_code('comcode_renderer');
        $_key = 'concept__' . preg_replace('#[^\w]#', '_', $key);
        $page_link = get_tutorial_link($_key);
        if ($page_link === null) {
            $temp_tpl = make_string_tempcode($key);
        } else {
            list($zone, $attributes, $hash) = page_link_decode($page_link);
            if ($zone == get_zone_name() && $attributes['page'] == get_page_name()) {
                $_url = make_string_tempcode('#' . $hash);
            } else {
                $_url = build_url($attributes, $zone, [], false, false, false, $hash);
            }
            $temp_tpl = do_template('COMCODE_CONCEPT', ['_GUID' => 'ee0cd05f87329923f05145180004d8a8', 'TEXT' => $key, 'URL' => $_url]);
        }
        $value = $temp_tpl->evaluate();
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }

    return $value;
}

// These directives are all static evaluated during compilation, so don't need loading on each request.

/**
 * Evaluate a particular Tempcode directive.
 *
 * @ignore
 *
 * @param  string $value Value to write into
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 */
function ecv2_RECONTEXTUALISE_IDS(string &$value, string $lang, array $escaped, array $param)
{
    if (isset($param[1])) {
        $prefix = $param[0]->evaluate();
        $str = $param[1]->evaluate();
        $matches = [];
        $num_matches = preg_match_all('# id="([^"]*)"#', $str, $matches);
        for ($i = 0; $i < $num_matches; $i++) {
            $str = str_replace(' id="' . $matches[$i][1] . '"', ' id="' . $prefix . '_' . $matches[$i][1] . '"', $str);
            $str = str_replace(' for="' . $matches[$i][1] . '"', ' for="' . $prefix . '_' . $matches[$i][1] . '"', $str);
            $str = str_replace(' ById(\'' . $matches[$i][1] . '\')', ' ById(\'' . $prefix . '_' . $matches[$i][1] . '\')', $str);
            $str = str_replace(' ById("' . $matches[$i][1] . '\')', ' ById(\'' . $prefix . '_' . $matches[$i][1] . '")', $str);
        }
        $value = $str;
    }
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_IS_MAINTAINED(string $lang, array $escaped, array $param) : string
{
    if (empty($param[1])) {
        $value = (is_maintained($param[0]) ? '1' : '0');
    } else {
        $value = static_evaluate_tempcode(is_maintained_description($param[0], $param[1]));
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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
 * @return string The result
 */
function ecv2_GENERATE_CAPTCHA(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (addon_installed('captcha')) {
        require_code('captcha');
        generate_captcha();
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_TAX_LABEL(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (addon_installed('ecommerce')) {
        require_lang('ecommerce');
        $value = do_lang(get_option('tax_system'));
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_TAX_NUMBER_LABEL(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (addon_installed('ecommerce')) {
        require_lang('ecommerce');
        $value = do_lang(get_option('tax_system') . '_NUMBER');
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_BUSINESS_ADDRESS(string $lang, array $escaped, array $param) : string
{
    $value = '';

    if (addon_installed('ecommerce')) {
        require_code('ecommerce');
        $value = get_full_business_address();
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_FLOAT_UNFORMAT(string $lang, array $escaped, array $param) : string
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $value = float_to_raw_string(float_unformat($param[0]), 10, true);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_THEME_SEED(string $lang, array $escaped, array $param) : string
{
    require_code('themes2');
    $value = find_theme_seed($GLOBALS['FORUM_DRIVER']->get_theme());

    if ((addon_installed('themewizard')) && (function_exists('has_privilege')) && (has_privilege(get_member(), 'view_profiling_modes'))) {
        $keep_theme_seed = get_param_string('keep_theme_seed', null);
        if ($keep_theme_seed !== null) {
            $value = $keep_theme_seed;
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }

    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_THEME_DARK(string $lang, array $escaped, array $param) : string
{
    global $IN_MINIKERNEL_VERSION;

    $value = '0';

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!$IN_MINIKERNEL_VERSION) {
        if (addon_installed('themewizard')) {
            require_code('themewizard');
            $value = find_theme_dark($GLOBALS['FORUM_DRIVER']->get_theme()) ? '1' : '0';
        }

        if ((addon_installed('themewizard')) && (function_exists('has_privilege')) && (has_privilege(get_member(), 'view_profiling_modes'))) {
            $keep_theme_dark = get_param_integer('keep_theme_dark', null);
            if ($keep_theme_dark !== null) {
                $value = (($keep_theme_dark == 1) ? '1' : '0');
            }
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }

    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_THEME_COLOUR_IS_BRIGHT(string $lang, array $escaped, array $param) : string
{
    global $IN_MINIKERNEL_VERSION;

    $value = '0';

    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!$IN_MINIKERNEL_VERSION) {
        if (addon_installed('themewizard')) {
            require_code('themewizard');
            if (strlen($param[0]) == 7) {
                $r = floatval(hexdec(substr($param[0], 1, 2)));
                $g = floatval(hexdec(substr($param[0], 3, 2)));
                $b = floatval(hexdec(substr($param[0], 5, 2)));

                $_value = rgb_luminance($r, $g, $b);

                if ($_value >= 0.5) {
                    $value = '1';
                }
            } elseif(strlen($param[0]) == 4) {
                $r = floatval(hexdec(substr($param[0], 1, 1) . '0'));
                $g = floatval(hexdec(substr($param[0], 2, 1) . '0'));
                $b = floatval(hexdec(substr($param[0], 3, 2) . '0'));

                $_value = rgb_luminance($r, $g, $b);

                if ($_value >= 0.5) {
                    $value = '1';
                }
            }
        }
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }

    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_KEEP_POST(string $lang, array $escaped, array $param) : string
{
    $value = static_evaluate_tempcode(build_keep_post_fields($param));
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (!empty($escaped)) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_DO_NOT_TRACK_REQUESTED(string $lang, array $escaped, array $param) : string
{
    $safe = '';
    if (function_exists('getallheaders')) {
        $headers = getallheaders();
        if (isset($headers['DNT'])) {
            $dnt = $headers['DNT'];
        }
    } elseif (isset($_SERVER['DNT'])) {
        $dnt = $_SERVER['DNT'];
    }
    return $dnt;
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_GEOCODE_ENABLED(string $lang, array $escaped, array $param) : string
{
    require_code('locations_geocoding');
    return (choose_geocoding_service() === null) ? '0' : '1';
}

/**
 * Evaluate a particular Tempcode directive.
 *
 * @ignore
 *
 * @param  string $value Value to write into
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 */
function ecv2_WHILE(string &$value, string $lang, array $escaped, array $param)
{
    if (isset($param[1])) {
        $_p = $param[0]->evaluate();
        if ($_p == '1') {
            $value = '';
            $value .= $param[1]->evaluate();
            $put = '';
            ecv2_WHILE($put, $lang, $escaped, $param);
            $value .= $put;
        }
    }
}

/**
 * Evaluate a particular Tempcode symbol.
 *
 * @ignore
 *
 * @param  LANGUAGE_NAME $lang The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array $escaped Array of escaping operations
 * @param  array $param 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.
 * @return string The result
 */
function ecv2_CURRENT_FATALISTIC(string $lang, array $escaped, array $param) : string
{
    return strval(current_fatalistic());
}
