Beispiel #1
0
/**
 * Get a splurghified version of the specified item.
 *
 * @param  string			The name of what the key we want to reference is in our array of maps (e.g. 'id')
 * @param  array			A row of maps for data we are splurghing; this is probably just the result of $GLOBALS['SITE_DB']->query_select
 * @param  URLPATH		The stub that links will be passed through
 * @param  ID_TEXT		The page name we will be saving customised HTML under
 * @param  TIME			The time we did our last change to the data being splurghed (so it can see if we can simply decache instead of deriving)
 * @param  ?AUTO_LINK	The ID that is at the root of our tree (NULL: db_get_first_id)
 * @return string			A string of HTML that represents our splurghing (will desplurgh in the users browser)
 */
function splurgh_master_build($key_name, $map, $url_stub, $_cache_file, $last_change_time, $first_id = NULL)
{
    if (is_null($first_id)) {
        $first_id = db_get_first_id();
    }
    if (!array_key_exists($first_id, $map)) {
        return '';
    }
    if (!has_js()) {
        warn_exit(do_lang_tempcode('MSG_JS_NEEDED'));
    }
    require_javascript('javascript_splurgh');
    if (is_browser_decacheing()) {
        $last_change_time = time();
    }
    $cache_file = zone_black_magic_filterer(get_custom_file_base() . '/' . get_zone_name() . '/pages/html_custom/' . filter_naughty(user_lang()) . '/' . filter_naughty($_cache_file) . '.htm');
    if (!file_exists($cache_file) || is_browser_decacheing() || filesize($cache_file) == 0 || $last_change_time > filemtime($cache_file)) {
        $myfile = @fopen($cache_file, 'wt');
        if ($myfile === false) {
            intelligent_write_error($cache_file);
        }
        $fulltable = array();
        $splurgh = _splurgh_do_node($map, $first_id, '', $fulltable, 0);
        $page = do_template('SPLURGH', array('_GUID' => '8775edfc5a386fdf2cec69b0fc889952', 'KEY_NAME' => $key_name, 'URL_STUB' => $url_stub, 'SPLURGH' => str_replace('"', '\'', $splurgh)));
        $ev = $page->evaluate();
        if (fwrite($myfile, $ev) < strlen($ev)) {
            warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
        }
        fclose($myfile);
        fix_permissions($cache_file);
        sync_file($cache_file);
        return $ev;
    }
    return file_get_contents($cache_file, FILE_TEXT);
}
/**
 * Put the contents of a page inside an iframe. This is typically used when a page is being used to traverse a result-set that spans multiple screens.
 *
 * @param  tempcode		The title
 * @param  ?integer		The time between refreshes (NULL: do not refresh)
 * @param  ?mixed			Data. A refresh will only happen if an AJAX-check indicates this data has changed (NULL: no check)
 * @return ?tempcode		The page output to finish off our current page stream such that it will spawn the iframe (NULL: not internalised)
 */
function internalise_own_screen($title, $refresh_time = NULL, $refresh_if_changed = NULL)
{
    if (get_value('no_frames') === '1' || get_param_integer('no_frames', 0) == 1 || get_param_integer('keep_no_frames', 0) == 1) {
        return NULL;
    }
    if (!has_js()) {
        return NULL;
    }
    // We need JS to make this a seamless process
    if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) {
        return NULL;
    }
    // This is already in the iframe
    require_javascript('javascript_ajax');
    require_javascript('javascript_iframe_screen');
    $url = find_script('iframe') . '?zone=' . rawurlencode(get_zone_name()) . '&wide_high=1&utheme=' . rawurlencode($GLOBALS['FORUM_DRIVER']->get_theme());
    foreach (array_merge($_GET, $_POST) as $key => $param) {
        if (!is_string($param)) {
            continue;
        }
        if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
            continue;
        }
        if (get_magic_quotes_gpc()) {
            $param = stripslashes($param);
        }
        $url .= '&' . $key . '=' . urlencode($param);
    }
    if (!is_null($refresh_if_changed)) {
        require_javascript('javascript_sound');
        $change_detection_url = find_script('change_detection') . '?whatever=1';
        foreach ($_GET as $key => $param) {
            if (!is_string($param)) {
                continue;
            }
            if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
                continue;
            }
            if (get_magic_quotes_gpc()) {
                $param = stripslashes($param);
            }
            $change_detection_url .= '&' . $key . '=' . urlencode($param);
        }
    } else {
        $refresh_if_changed = '';
        $change_detection_url = '';
    }
    return do_template('IFRAME_SCREEN', array('_GUID' => '06554eb227428fd5c648dee3c5b38185', 'TITLE' => $title, 'REFRESH_IF_CHANGED' => md5(serialize($refresh_if_changed)), 'CHANGE_DETECTION_URL' => $change_detection_url, 'REFRESH_TIME' => is_null($refresh_time) ? '' : strval($refresh_time), 'IFRAME_URL' => $url));
}
Beispiel #3
0
/**
 * Render a member profile.
 *
 * @param  MEMBER			The ID of the member who is being viewed
 * @param  ?MEMBER		The ID of the member who is doing the viewing (NULL: current member)
 * @param  ?ID_TEXT		The username of the member who is being viewed (NULL: work out from member_id_of)
 * @return tempcode		The rendered profile
 */
function render_profile_tabset($member_id_of, $member_id_viewing = NULL, $username = NULL)
{
    if (is_null($member_id_viewing)) {
        $member_id_viewing = get_member();
    }
    $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($username) || is_guest($member_id_of)) {
        warn_exit(do_lang_tempcode('USER_NO_EXIST'));
    }
    $tabs = array();
    $hooks = find_all_hooks('systems', 'profiles_tabs');
    if (isset($hooks['edit'])) {
        $hooks = array('edit' => $hooks['edit']) + $hooks;
    }
    foreach (array_keys($hooks) as $hook) {
        require_code('hooks/systems/profiles_tabs/' . $hook);
        $ob = object_factory('Hook_Profiles_Tabs_' . $hook);
        if ($ob->is_active($member_id_of, $member_id_viewing)) {
            $tabs[$hook] = $ob->render_tab($member_id_of, $member_id_viewing, !browser_matches('ie6') && !browser_matches('ie7') && has_js());
        }
    }
    global $M_SORT_KEY;
    $M_SORT_KEY = 2;
    uasort($tabs, 'multi_sort');
    require_javascript('javascript_profile');
    require_javascript('javascript_ajax');
    load_up_all_self_page_permissions($member_id_viewing);
    if (addon_installed('awards')) {
        require_code('awards');
        $awards = find_awards_for('member', strval($member_id_of));
    } else {
        $awards = array();
    }
    $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    // Get it again, in case it changed
    $title = get_page_title('MEMBER_PROFILE', true, array(escape_html($username)), NULL, $awards);
    $_tabs = array();
    $i = 0;
    foreach ($tabs as $hook => $tab) {
        $_tabs[] = array('TAB_TITLE' => $tab[0], 'TAB_CODE' => $hook, 'TAB_CONTENT' => $tab[1], 'TAB_FIRST' => $i == 0, 'TAB_LAST' => !array_key_exists($i + 1, $tabs));
        $i++;
    }
    return do_template('OCF_MEMBER_PROFILE_SCREEN', array('TITLE' => $title, 'TABS' => $_tabs, 'MEMBER_ID' => strval($member_id_of)));
}
Beispiel #4
0
/**
 * Render a menu branch to tempcode.
 *
 * @param  array			The menu branch map
 * @param  SHORT_TEXT	An identifier for the menu (will be used as a unique id by menu javascript code)
 * @param  MEMBER			The member the menu is being built as
 * @param  integer		The depth into the menu that this branch resides at
 * @param  ID_TEXT		The menu type (determines what templates get used)
 * @param  boolean		Whether to generate Comcode with admin privilege
 * @param  array			Array of all other branches
 * @param  integer		The level
 * @return array			A pair: array of parameters of the menu branch (or NULL if unrenderable, or Tempcode of something to attach), and whether it is expanded
 */
function render_menu_branch($branch, $codename, $source_member, $level, $type, $as_admin, $all_branches, $the_level = 1)
{
    global $REDIRECTED_TO;
    $caption = mixed();
    // Initialise type to mixed
    if (is_string($branch['caption']) && strpos($branch['caption'], '[') !== false) {
        $caption = comcode_to_tempcode($branch['caption'], $source_member, $as_admin);
    } else {
        $caption = $branch['caption'];
    }
    if (!is_null($branch['only_on_page']) && $branch['only_on_page'] != '') {
        if (strpos($branch['only_on_page'], '{') !== false) {
            require_code('tempcode_compiler');
            $branch['only_on_page'] = static_evaluate_tempcode(template_to_tempcode($branch['only_on_page']));
        }
        if ($branch['only_on_page'] != '' && !match_key_match($branch['only_on_page'])) {
            return array(NULL, false);
        }
        // We are not allowed to render this on this page
    }
    $current_zone = false;
    $current_page = false;
    $expand_this = false;
    $tooltip = array_key_exists('caption_long', $branch) ? $branch['caption_long'] : '';
    if (is_null($tooltip)) {
        $tooltip = '';
    }
    // Caused by corrupt in DB. translate table join failed due to corrupt lang string reference
    $dp = $GLOBALS['ZONE']['zone_default_page'];
    $url = mixed();
    // Spacers
    if ($branch['type'] == 'blank') {
        return array(do_template('MENU_SPACER_' . filter_naughty_harsh($type), array('MENU' => $codename, 'TOP_LEVEL' => $the_level == 1, 'THE_LEVEL' => strval($the_level), 'CURRENT' => $current_page, 'CURRENT_ZONE' => $current_zone), NULL, false, 'MENU_SPACER_tree'), false);
    }
    // Normal branches...
    $users_current_zone = get_zone_name();
    // Work out the final URL to use
    $url = $branch['special'];
    if (is_object($url)) {
        if (isset($url->seq_parts) && isset($url->seq_parts[0]) && $url->seq_parts[0][3] == 'PAGE_LINK') {
            $url = $url->seq_parts[0][1][0];
            if (is_object($url)) {
                $url = $url->evaluate();
            }
        } elseif (isset($url->bits) && isset($url->bits[0]) && $url->bits[0][2] == 'PAGE_LINK') {
            $url = $url->bits[0][3][0];
            if (is_object($url)) {
                $url = $url->evaluate();
            }
        } elseif (substr($url->evaluate(), 0, strlen(get_base_url())) == get_base_url()) {
            $page_link = url_to_pagelink($url->evaluate(), true, true);
            if ($page_link != '') {
                $url = $page_link;
            }
        }
    }
    if (!is_object($url)) {
        $parts = array();
        if (preg_match('#([\\w-]*):([\\w-]+|[^/]|$)((:(.*))*)#', $url, $parts) != 0 && $parts[1] != 'mailto') {
            $page_link = $url;
            list($zone_name, $map, $hash) = page_link_decode($url);
            if ($zone_name == 'forum' && get_forum_type() != 'ocf') {
                return array(NULL, false);
            }
            if (!isset($map['page'])) {
                $map['page'] = get_zone_default_page($zone_name);
            }
            // If we need to check access
            if (array_key_exists('check_perms', $branch['modifiers'])) {
                if (!has_zone_access(get_member(), $zone_name)) {
                    return array(NULL, false);
                }
                if (!has_page_access(get_member(), $map['page'], $zone_name)) {
                    return array(NULL, false);
                }
            }
            // Scan for Tempcode symbols etc
            foreach ($map as $key => $val) {
                if (strpos($val, '{') !== false) {
                    require_code('tempcode_compiler');
                    $map[$key] = template_to_tempcode($val);
                }
            }
            $url = build_url($map, $zone_name, NULL, false, false, false, $hash);
            // See if this is current page
            $somewhere_definite = false;
            $_parts = array();
            foreach ($all_branches as $_branch) {
                if (!is_string($_branch['special'])) {
                    continue;
                }
                if (preg_match('#([\\w-]*):([\\w-]+|[^/]|$)((:(.*))*)#', $_branch['special'], $_parts) != 0) {
                    if ($_parts[1] == $users_current_zone) {
                        $somewhere_definite = true;
                    }
                }
            }
            $current_zone = $zone_name == $users_current_zone || !is_null($REDIRECTED_TO) && $zone_name == $REDIRECTED_TO['r_to_zone'] && !$somewhere_definite;
            // This code is a bit smart, as zone menus usually have a small number of zones on them - redirects will be counted into the zone redirected to, so long as there is no more suitable zone and so long as it is not a transparent redirect
            if ($zone_name == $users_current_zone || !is_null($REDIRECTED_TO) && $zone_name == $REDIRECTED_TO['r_to_zone'] && array_key_exists('page', $map) && $map['page'] == $REDIRECTED_TO['r_to_page']) {
                $current_page = true;
                foreach ($map as $k => $v) {
                    if (is_integer($v)) {
                        $v = strval($v);
                    }
                    if (is_object($v)) {
                        $v = $v->evaluate();
                    }
                    if ($v == '' && $k == 'page') {
                        $v = 'start';
                        if ($zone_name == $users_current_zone) {
                            global $ZONE;
                            $v = $ZONE['zone_default_page'];
                        }
                    }
                    $pv = get_param($k, $k == 'page' ? $dp : NULL, true);
                    if ($pv !== $v && ($k != 'page' || is_null($REDIRECTED_TO) || !is_null($REDIRECTED_TO) && ($v !== $REDIRECTED_TO['r_to_page'] || $zone_name != $REDIRECTED_TO['r_to_zone'])) && ($k != 'type' || $v != 'misc') && ($v != $dp || $k != 'page' || get_param('page', '') != '') && substr($k, 0, 5) != 'keep_') {
                        $current_page = false;
                        break;
                    }
                }
            }
        } else {
            $page_link = '';
            $sym_pos = mixed();
            $sym_pos = is_null($url) ? false : strpos($url, '{$');
            if ($sym_pos !== false) {
                $_url = new ocp_tempcode();
                $len = strlen($url);
                $prev = 0;
                do {
                    $p_len = $sym_pos + 1;
                    $balance = 1;
                    while ($p_len < $len && $balance != 0) {
                        if ($url[$p_len] == '{') {
                            $balance++;
                        } elseif ($url[$p_len] == '}') {
                            $balance--;
                        }
                        $p_len++;
                    }
                    $_url->attach(substr($url, $prev, $sym_pos - $prev));
                    $_ret = new ocp_tempcode();
                    $_ret->parse_from($url, $sym_pos, $p_len);
                    $_url->attach($_ret);
                    $prev = $p_len;
                    $sym_pos = strpos($url, '{$', $sym_pos + 1);
                } while ($sym_pos !== false);
                $_url->attach(substr($url, $prev));
                $url = $_url;
            }
        }
    } else {
        $page_link = NULL;
    }
    // Children
    $children = new ocp_tempcode();
    $display = 'block';
    if ($branch['type'] == 'drawer') {
        $new_children = array();
        foreach ($branch['children'] as $i => $child) {
            list($children2, $_expand_this) = render_menu_branch($child, $codename, $source_member, $level + 1, $type, $as_admin, $all_branches, $the_level + 1);
            if ($_expand_this) {
                $expand_this = true;
            }
            if ($children2 !== '' && !is_null($children2)) {
                $new_children[] = $children2;
            }
        }
        $num = count($new_children);
        foreach ($new_children as $i => $child) {
            if (is_object($child)) {
                $children->attach($child);
            } else {
                $children->attach(do_template('MENU_BRANCH_' . filter_naughty_harsh($type), $child + array('POSITION' => strval($i), 'LAST' => $i == $num - 1, 'BRETHREN_COUNT' => strval($num)), NULL, false, 'MENU_BRANCH_tree'));
            }
        }
        if ($children->is_empty()) {
            return array(NULL, false);
        }
        // Nothing here!
        if (!array_key_exists('expanded', $branch['modifiers']) && !$expand_this && !$current_page) {
            $display = has_js() ? 'none' : 'block';
            // We remap to 'none' using JS. If no JS, it remains visible. Once we have learn't we have JS, we don't need to do it again
        } else {
            $display = 'block';
        }
    }
    // Data cleanups
    $escape = is_string($caption) && !array_key_exists('comcode', $branch['modifiers']);
    if ($escape) {
        $caption = escape_html($caption);
    }
    // Access key
    if ($page_link === '_SEARCH:help') {
        $accesskey = '6';
    } elseif ($page_link === '_SEARCH:rules') {
        $accesskey = '7';
    } elseif ($page_link === '_SEARCH:staff:type=misc') {
        $accesskey = '5';
    } else {
        $accesskey = '';
    }
    // Other properties
    $popup = array_key_exists('popup', $branch['modifiers']);
    $popup_width = '';
    $popup_height = '';
    if ($popup) {
        $popup_width = strval($branch['width']);
        $popup_height = strval($branch['height']);
    }
    $new_window = array_key_exists('new_window', $branch['modifiers']);
    // Render!
    $rendered_branch = array('RANDOM' => substr(md5(uniqid('')), 0, 7), 'CAPTION' => $caption, 'IMG' => array_key_exists('img', $branch) ? $branch['img'] : '', 'URL' => $url, 'PAGE_LINK' => $page_link, 'ACCESSKEY' => $accesskey, 'POPUP' => $popup, 'POPUP_WIDTH' => $popup_width, 'POPUP_HEIGHT' => $popup_height, 'NEW_WINDOW' => $new_window, 'TOOLTIP' => $tooltip, 'CHILDREN' => $children, 'DISPLAY' => $display, 'MENU' => $codename, 'TOP_LEVEL' => $the_level == 1, 'THE_LEVEL' => strval($the_level), 'CURRENT' => $current_page, 'CURRENT_ZONE' => $current_zone);
    return array($rendered_branch, $current_page || $expand_this);
}
Beispiel #5
0
 /**
  * The form element for choosing a post template.
  *
  * @param  AUTO_LINK		The forum ID we are looking for post templates active in
  * @return array			A pair: The form element (tempcode) and the default post to make
  */
 function post_templates($forum_id)
 {
     if (!addon_installed('ocf_post_templates')) {
         return array(new ocp_tempcode(), '');
     }
     $specialisation = new ocp_tempcode();
     $templates = $this->ocf_get_post_templates($forum_id);
     $post_templates = new ocp_tempcode();
     $post = '';
     foreach ($templates as $template) {
         list($title, $text, $default) = $template;
         if ($default) {
             $post = $text;
         }
         $post_templates->attach(form_input_list_entry(str_replace(chr(10), '\\n', $text), $default == 1, $title));
     }
     if (!$post_templates->is_empty() && has_js()) {
         $post_templates2 = form_input_list_entry('', false, do_lang_tempcode('NA_EM'));
         $post_templates2->attach($post_templates);
         $input = do_template('OCF_POST_TEMPLATE_SELECT', array('_GUID' => '2e4270e8fb8050f0201f5aa2af56270a', 'TABINDEX' => '3', 'LIST' => $post_templates2));
         $specialisation->attach(_form_input('post_template', do_lang_tempcode('POST_TEMPLATE'), do_lang_tempcode('DESCRIPTION_POST_TEMPLATE'), $input, false, false));
     }
     return array($specialisation, $post);
 }
Beispiel #6
0
 /**
  * Get form inputter.
  *
  * @param  string			The field name
  * @param  string			The field description
  * @param  array			The field details
  * @param  ?string		The actual current value of the field (NULL: none)
  * @param  boolean		Whether this is for a new entry
  * @param  boolean		Whether this is the last field in the catalogue
  * @return ?tempcode		The Tempcode for the input field (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new, $last = true)
 {
     if (is_null($actual_value)) {
         $actual_value = '';
     }
     // Plug anomaly due to unusual corruption
     require_lang('javascript');
     require_javascript('javascript_posting');
     require_javascript('javascript_editing');
     require_javascript('javascript_ajax');
     require_javascript('javascript_swfupload');
     require_css('swfupload');
     require_lang('comcode');
     $tabindex = get_form_field_tabindex();
     $actual_value = filter_form_field_default($_cf_name, $actual_value);
     list($attachments, $attach_size_field) = get_attachments('field_' . strval($field['id']));
     $hidden_fields = new ocp_tempcode();
     $hidden_fields->attach($attach_size_field);
     $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
     $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser('field_' . strval($field['id']));
     $comcode_editor = get_comcode_editor('field_' . strval($field['id']));
     $comcode_editor_small = get_comcode_editor('field_' . strval($field['id']), true);
     $w = has_js() && (browser_matches('wysiwyg') && strpos($actual_value, '{$,page hint: no_wysiwyg}') === false);
     $class = '';
     global $JAVASCRIPT, $WYSIWYG_ATTACHED;
     if (!$WYSIWYG_ATTACHED) {
         $JAVASCRIPT->attach(do_template('HTML_EDIT'));
     }
     $WYSIWYG_ATTACHED = true;
     @header('Content-type: text/html; charset=' . get_charset());
     if ($w) {
         $class .= ' wysiwyg';
     }
     global $LAX_COMCODE;
     $temp = $LAX_COMCODE;
     $LAX_COMCODE = true;
     $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100;
     // Little hack to stop it checking any URLs
     /*if (is_null($default_parsed)) */
     $default_parsed = comcode_to_tempcode($actual_value, NULL, false, 60, NULL, NULL, true);
     $LAX_COMCODE = $temp;
     $attachments_done = true;
     $ret = do_template('POSTING_FIELD', array('REQUIRED' => $field['cf_required'] == 1, 'DESCRIPTION' => $_cf_description, 'HIDDEN_FIELDS' => $hidden_fields, 'PRETTY_NAME' => $_cf_name, 'NAME' => 'field_' . strval($field['id']), 'TABINDEX_PF' => strval($tabindex), 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EMOTICON_CHOOSER' => $emoticon_chooser, 'COMCODE_HELP' => $comcode_help, 'POST' => $actual_value, 'DEFAULT_PARSED' => $default_parsed, 'ATTACHMENTS' => $attachments));
     if (!$last) {
         $ret->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ADDITIONAL_INFO'))));
     }
     return $ret;
 }
Beispiel #7
0
/**
 * The do-next manager for after content management.
 *
 * @param  tempcode		The title (output of get_page_title)
 * @param  ?ID_TEXT		The name of the page just handled (NULL: none)
 * @param  ID_TEXT		The name of the zone just handled (blank: none/welcome-zone)
 * @param  tempcode		The text to show (blank: default)
 * @return tempcode		The UI
 */
function site_tree_do_next_manager($title, $page, $zone, $completion_text)
{
    if ($completion_text->is_empty()) {
        $completion_text = do_lang_tempcode('SUCCESS');
    }
    require_code('templates_donext');
    $special = array(array('pagewizard', array('admin_sitetree', array('type' => 'pagewizard', 'zone' => $zone), get_module_zone('admin_sitetree')), do_lang_tempcode('PAGE_WIZARD')), array('comcode_page_edit', array('cms_comcode_pages', array('type' => 'misc'), get_module_zone('cms_comcode_pages')), do_lang_tempcode('COMCODE_PAGE_EDIT')));
    if (addon_installed('redirects_editor')) {
        require_lang('redirects');
        $special[] = array('redirect', array('admin_redirects', array('type' => 'misc'), get_module_zone('admin_redirects')), do_lang_tempcode('REDIRECTS'));
    }
    if (!has_js()) {
        $special = array_merge($special, array(array('delete', array('admin_sitetree', array('type' => 'delete'), get_module_zone('admin_sitetree')), do_lang_tempcode('DELETE_PAGES')), array('move', array('admin_sitetree', array('type' => 'move'), get_module_zone('admin_sitetree')), do_lang_tempcode('MOVE_PAGES'))));
    } else {
        $special = array_merge($special, array(array('sitetree', array('admin_sitetree', array('type' => 'site_tree'), get_module_zone('admin_sitetree')), do_lang_tempcode('SITE_TREE_EDITOR'))));
    }
    return do_next_manager($title, $completion_text, $special, do_lang('PAGES'), NULL, is_null($page) ? NULL : array('_SELF', array('type' => '_ed', 'page_link' => $zone . ':' . $page), '_SELF'), NULL, is_null($page) ? NULL : array($page, array(), $zone), NULL, NULL, NULL, NULL, NULL, NULL);
}
Beispiel #8
0
 /**
  * Standard modular UI to choose an entry to edit.
  *
  * @return tempcode	The UI
  */
 function ed()
 {
     if (!is_null($this->permissions_require) && is_null($this->permissions_cat_require)) {
         check_some_edit_permission($this->permissions_require, NULL, $this->permission_page_name);
     }
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     $test = $this->choose_catalogue($title);
     if (!is_null($test)) {
         return $test;
     }
     $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST'));
     $next_type = '_e' . $this->type_code;
     if (get_param('type', 'ed') == 'edit_catalogue') {
         $next_type = '_edit_catalogue';
     }
     $map = array('page' => '_SELF', 'type' => $next_type);
     if (either_param('catalogue_name', '') != '') {
         $map['catalogue_name'] = either_param('catalogue_name');
     }
     if (!is_null(get_param('redirect', NULL))) {
         $map['redirect'] = get_param('redirect');
     }
     if (!is_null(get_param('continue', NULL))) {
         $map['continue'] = get_param('continue');
     }
     $description = $this->select_name_description != '' ? do_lang_tempcode($this->select_name_description) : new ocp_tempcode();
     if (method_exists($this, 'nice_get_radio_entries')) {
         $entries = $this->nice_get_radio_entries();
         if ($entries->is_empty()) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $fields = form_input_radio(do_lang_tempcode($this->select_name), $description, 'id', $entries, $this->no_blank_ids, true, '');
     } elseif (method_exists($this, 'nice_get_ajax_tree') && ($_fields = $this->nice_get_ajax_tree()) !== NULL) {
         if (is_array($_fields)) {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($_fields[1]->evaluate()), escape_html($_fields[2]->evaluate())));
             $fields = $_fields[0];
         } else {
             $fields = $_fields;
         }
     } elseif (method_exists($this, 'nice_get_choose_table')) {
         list($test, ) = $this->get_entry_rows();
         if (count($test) == 0) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $table_result = $this->nice_get_choose_table($map);
         if (is_null($table_result)) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $table = $table_result[0];
         $has_ordering = $table_result[1];
         if (array_key_exists(2, $table_result) && !is_null($table_result[2])) {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_TABLE_EXTRA', escape_html($table_result[2]->evaluate()), escape_html($table_result[3]->evaluate())));
         } else {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_TABLE'));
         }
         return do_template('TABLE_TABLE_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'TABLE' => $table, 'SUBMIT_NAME' => $has_ordering ? do_lang_tempcode('ORDER') : NULL, 'POST_URL' => get_self_url()));
     } else {
         $_entries = $this->nice_get_entries();
         if (is_array($_entries)) {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($_entries[1]->evaluate()), escape_html($_entries[2]->evaluate())));
             $entries = $_entries[0];
         } else {
             $entries = $_entries;
         }
         if ($entries->is_empty()) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $fields = form_input_list(do_lang_tempcode($this->select_name), $description, 'id', $entries, NULL, true, $this->no_blank_ids);
     }
     $post_url = build_url($map, '_SELF', NULL, false, true);
     //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing);
     $submit_name = do_lang_tempcode('PROCEED');
     $keep = symbol_tempcode('KEEP');
     $iframe_url = NULL;
     if (!$this->special_edit_frontend && has_js()) {
         $iframe_url = find_script('iframe') . '?zone=' . get_zone_name() . '&wide_high=1&opens_below=1';
         foreach ($map as $key => $val) {
             $iframe_url .= '&' . $key . '=' . urlencode(str_replace('_SELF', get_page_name(), $val));
         }
         $iframe_url .= $keep->evaluate();
     }
     return do_template('FORM_SCREEN', array('_GUID' => '228a05e24253f324ea286ea8ac3d8b02' . get_class($this), 'GET' => true, 'IFRAME_URL' => $iframe_url, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'SKIP_VALIDATION' => true));
 }
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_javascript('javascript_realtime_rain');
     require_javascript('javascript_ajax');
     require_javascript('javascript_more');
     require_lang('realtime_rain');
     require_css('realtime_rain');
     $title = get_page_title('REALTIME_RAIN');
     if (!has_js()) {
         // Send them to the page permissions screen
         $url = build_url(array('page' => 'admin_stats', 'type' => 'misc'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_REALTIME')));
     }
     $GLOBALS['TEMPCODE_SETGET']['chrome_frame'] = make_string_tempcode('1');
     if (browser_matches('ie6')) {
         attach_message(do_lang_tempcode('IE_OLD_PLEASE_UPGRADE'), 'warn');
     }
     if (!has_js()) {
         // Send them to the stats screen
         $url = build_url(array('page' => 'admin_stats', 'type' => 'misc'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_REALTIME_RAIN')));
     }
     $min_time = $GLOBALS['SITE_DB']->query_value('stats', 'MIN(date_and_time)');
     if (is_null($min_time)) {
         $min_time = time();
     }
     return do_template('REALTIME_RAIN_OVERLAY', array('MIN_TIME' => strval($min_time)));
 }
Beispiel #10
0
/**
 * Checks an XHTML tag for validity, including attributes. Return the results.
 *
 * @param  string			The name of the tag to check
 * @param  map				A map of attributes (name=>value) the tag has
 * @param  boolean		Whether this is a self-closing tag
 * @param  boolean		Whether this is a closing tag
 * @param  list			Errors detected so far. We will add to these and return
 * @return array			Array of error information
 */
function __check_tag($tag, $attributes, $self_close, $close, $errors)
{
    global $XML_CONSTRAIN, $TAG_STACK, $ATT_STACK, $TABS_SEEN, $KEYS_SEEN, $IDS_SO_FAR, $ANCESTER_BLOCK, $ANCESTER_INLINE, $EXPECTING_TAG, $OUT, $POS, $LAST_A_TAG, $TAG_RANGES;
    // Dodgy mouse events.
    if (isset($attributes['onclick']) && !isset($attributes['onkeypress']) && !isset($attributes['onkeydown']) && !isset($attributes['onkeyup']) && !in_array($tag, array('a', 'input', 'textarea', 'select', 'button'))) {
        $errors[] = array('WCAG_MOUSE_EVENT_UNMATCHED');
    }
    if ($GLOBALS['VALIDATION_MANUAL']) {
        if (isset($attributes['onmouseover']) && !isset($attributes['onfocus']) && in_array($tag, array('a', 'area', 'button', 'input', 'label', 'select', 'textarea'))) {
            $errors[] = array('WCAG_MOUSE_EVENT_UNMATCHED');
        }
        if (isset($attributes['onmouseout']) && !isset($attributes['onblur']) && in_array($tag, array('a', 'area', 'button', 'input', 'label', 'select', 'textarea'))) {
            $errors[] = array('WCAG_MOUSE_EVENT_UNMATCHED');
        }
    }
    // Unexpected tags
    if (!is_null($EXPECTING_TAG) && $EXPECTING_TAG != $tag) {
        if ($EXPECTING_TAG == 'noscript') {
            if ($GLOBALS['VALIDATION_MANUAL']) {
                $errors[] = array('MANUAL_WCAG_SCRIPT');
            }
        } else {
            $errors[] = array('XHTML_EXPECTING', $EXPECTING_TAG);
        }
    }
    $EXPECTING_TAG = NULL;
    // Note that we do NOT take into account display:inline, because the W3C one doesn't either - probably because 'display' implies not 'semantic'
    $tmp = _check_blockyness($tag, $attributes, $self_close, $close);
    if (!is_null($tmp)) {
        $errors = array_merge($errors, $tmp);
    }
    if (array_key_exists('xmlns', $attributes)) {
        global $UNDER_XMLNS;
        $UNDER_XMLNS = true;
    }
    // Look for unknown attributes, or bad values
    $tmp = _check_attributes($tag, $attributes, $self_close, $close);
    if (!is_null($tmp)) {
        $errors = array_merge($errors, $tmp);
    }
    if (!$close) {
        if ($GLOBALS['MAIL_MODE']) {
            if (in_array($tag, array('style', 'object', 'applet', 'embed', 'form', 'map'))) {
                $errors[] = array('MAIL_BAD_TAG', $tag);
            }
            if ($tag == 'script') {
                $errors[] = array('MAIL_JAVASCRIPT');
            }
            foreach (array_keys($attributes) as $atr) {
                if (substr(strtolower($atr), 0, 2) == 'on') {
                    $errors[] = array('MAIL_JAVASCRIPT');
                }
            }
            if ($tag == 'body' && count($attributes) != 0 && $attributes != array('style' => 'margin: 0')) {
                $errors[] = array('MAIL_BODY');
            }
        }
        // Check all required attributes are here
        global $TAG_ATTRIBUTES_REQUIRED;
        if (isset($TAG_ATTRIBUTES_REQUIRED[$tag]) && ($tag != 'html' || $XML_CONSTRAIN)) {
            $diff = array_diff($TAG_ATTRIBUTES_REQUIRED[$tag], array_keys($attributes));
            foreach ($diff as $attribute) {
                $errors[] = array('XHTML_MISSING_ATTRIBUTE', $tag, $attribute);
            }
        }
        // Iframes and CSS sheets need external checking
        if ($GLOBALS['VALIDATION_EXT_FILES']) {
            $tmp = _check_externals($tag, $attributes, $self_close, $close);
            if (!is_null($tmp)) {
                $errors = array_merge($errors, $tmp);
            }
        }
        // Check our links are OK
        if ($tag == 'a' && isset($attributes['href'])) {
            if (substr($attributes['href'], 0, 5) == 'mailto:' && strpos($attributes['href'], '&') === false && strpos($attributes['href'], 'unsubscribe') !== false) {
                $errors[] = array('XHTML_SPAM');
            }
            $tmp = _check_link_accessibility($tag, $attributes, $self_close, $close);
            if (!is_null($tmp)) {
                $errors = array_merge($errors, $tmp);
            }
        }
        // Embed is a special case
        //		if (($tag=='embed') && (!$self_close)) $EXPECTING_TAG='noembed';
        if ($tag == 'fieldset' && !$self_close) {
            $EXPECTING_TAG = 'legend';
        }
    } else {
        if ($tag == 'a') {
            $LAST_A_TAG = $TAG_RANGES[count($TAG_RANGES) - 1][1];
        }
    }
    // Check our form labelling is OK
    $tmp = _check_labelling($tag, $attributes, $self_close, $close);
    if (!is_null($tmp)) {
        $errors = array_merge($errors, $tmp);
    }
    if (!$close) {
        if ($tag == 'input' || $tag == 'select') {
            if ($GLOBALS['VALIDATION_MANUAL'] && isset($attributes['name']) && strpos(strtolower($GLOBALS['OUT']), 'privacy') === false) {
                $privacy = array('dob', 'name', 'age', 'address', 'date_of_birth', 'dateofbirth', 'email', 'e_mail', 'gender', 'salutation');
                foreach ($privacy as $priv) {
                    if (strpos(strtolower($attributes['name']), $priv) !== false) {
                        $errors[] = array('MANUAL_PRIVACY');
                    }
                }
            }
        }
        switch ($tag) {
            case 'meta':
                if ($GLOBALS['VALIDATION_MANUAL'] && isset($attributes['name']) && $attributes['name'] == 'robots') {
                    $errors[] = array('MANUAL_META');
                }
                if (isset($attributes['http-equiv']) && isset($attributes['content']) && strtolower($attributes['http-equiv']) == 'content-type' && (strpos($attributes['content'], 'text/html;') !== false || strpos($attributes['content'], 'application/xhtml+xml;') !== false) && strpos($attributes['content'], 'charset=') !== false) {
                    $GLOBALS['FOUND_CONTENTTYPE'] = true;
                }
                if (isset($attributes['content']) && $attributes['content'] != '') {
                    if (isset($attributes['name']) && $attributes['name'] == 'keywords') {
                        $GLOBALS['FOUND_KEYWORDS'] = true;
                    }
                    if (isset($attributes['name']) && $attributes['name'] == 'description') {
                        $GLOBALS['FOUND_DESCRIPTION'] = true;
                    }
                }
                break;
            case 'blockquote':
                if ($GLOBALS['VALIDATION_MANUAL']) {
                    $errors[] = array('MANUAL_WCAG_SEMANTIC_BLOCKQUOTE');
                }
                break;
            case 'ul':
            case 'ol':
            case 'dl':
                if ($GLOBALS['VALIDATION_MANUAL']) {
                    $errors[] = array('MANUAL_WCAG_SEMANTIC_LIST');
                }
                break;
            case 'script':
                if ($GLOBALS['VALIDATION_MANUAL']) {
                    $errors[] = array('MANUAL_WCAG_ANIMATION');
                    $EXPECTING_TAG = 'noscript';
                }
                if ($GLOBALS['VALIDATION_JAVASCRIPT'] && (!isset($attributes['type']) || isset($attributes['type']) && ($attributes['type'] == 'text/javascript' || $attributes['type'] == 'application/x-javascript'))) {
                    if (function_exists('require_code')) {
                        require_code('js_validator');
                    }
                    $content = substr($OUT, $POS, strpos($OUT, '</script>', $POS) - $POS);
                    // Whilst the </table> found may not be the closing tag to our table, we do know a <th> should occur before any such one (unless it's a really weird table layout)
                    $content = preg_replace('#((<![CDATA[)|(]]>)|(<!--)|(-->))#', '', $content);
                    $js_validity = check_js($content, true);
                    if (is_array($js_validity)) {
                        $errors = array_merge($errors, $js_validity);
                    }
                    // Some kind of error
                }
                break;
            case 'style':
                if ($GLOBALS['VALIDATION_CSS'] && (!isset($attributes['type']) || isset($attributes['type']) && $attributes['type'] == 'text/css')) {
                    $content = substr($OUT, $POS, strpos($OUT, '</style>', $POS) - $POS);
                    // Whilst the </table> found may not be the closing tag to our table, we do know a <th> should occur before any such one (unless it's a really weird table layout)
                    $content = preg_replace('#((<![CDATA[)|(]]>)|(<!--)|(-->))#', '', $content);
                    $css_validity = _validate_css_sheet($content);
                    if (is_array($css_validity)) {
                        $errors = array_merge($errors, $css_validity);
                    }
                    // Some kind of error
                }
                break;
            case 'area':
                global $AREA_LINKS;
                if (isset($attributes['href'])) {
                    $AREA_LINKS[@html_entity_decode($attributes['href'], ENT_QUOTES, get_charset())] = 1;
                }
                break;
            case 'base':
                global $URL_BASE;
                if (isset($attributes['href'])) {
                    $URL_BASE = @html_entity_decode($attributes['href'], ENT_QUOTES, get_charset());
                }
                break;
            case 'form':
                if (isset($attributes['action']) && strpos($attributes['action'], '?') !== false && isset($attributes['method']) && $attributes['method'] == 'get') {
                    $errors[] = array('XHTML_FORM_TYPE');
                }
                $GLOBALS['XHTML_FORM_ENCODING'] = isset($attributes['enctype']) ? $attributes['enctype'] : 'application/x-www-form-urlencoded';
                if (isset($attributes['target']) && $attributes['target'] == '_blank' && (!isset($attributes['title']) || strpos($attributes['title'], do_lang('LINK_NEW_WINDOW')) === false)) {
                    $errors[] = array('WCAG_BLANK');
                }
                if ($GLOBALS['XHTML_FORM_ENCODING'] == 'multipart/form-data' && array_key_exists('method', $attributes) && $attributes['method'] == 'get') {
                    $errors[] = array('XHTML_FORM_ENCODING_2');
                }
            case 'map':
            case 'iframe':
            case 'object':
                // We can't check for the 'a' tag because it is rendered if given both a name and an ID
                if (isset($attributes['name'])) {
                    global $ANCHORS_SEEN;
                    if (isset($ANCHORS_SEEN[$attributes['name']])) {
                        $errors[] = array('XHTML_A_NAME', $tag);
                    } else {
                        $ANCHORS_SEEN[$attributes['name']] = 1;
                    }
                    if (!isset($attributes['id']) || isset($attributes['id']) && $attributes['id'] != $attributes['name']) {
                        $errors[] = array('XHTML_NAME_ID_DEPRECATED');
                    }
                }
                // elseif ((isset($attributes['id'])) && (!isset($attributes['href']))) $errors[]=array('XHTML_NAME_ID_DEPRECATED');
                break;
            case 'input':
                if (isset($attributes['type'])) {
                    // Special case for missing 'name' in form elements
                    if ($attributes['type'] != 'image' && $attributes['type'] != 'submit' && $attributes['type'] != 'button' && $attributes['type'] != 'reset') {
                        if (!isset($attributes['name'])) {
                            $errors[] = array('XHTML_MISSING_ATTRIBUTE', $tag, 'name');
                        }
                    }
                    if ($attributes['type'] == 'image' && !isset($attributes['alt'])) {
                        $errors[] = array('XHTML_MISSING_ATTRIBUTE', 'input', 'alt');
                    }
                    if ($attributes['type'] == 'file') {
                        if (isset($attributes['value'])) {
                            $errors[] = array('XHTML_FILE_VALUE');
                        }
                        if ($GLOBALS['XHTML_FORM_ENCODING'] != 'multipart/form-data' && $GLOBALS['XHTML_FORM_ENCODING'] != '') {
                            $errors[] = array('XHTML_FORM_ENCODING');
                        }
                    } elseif ($attributes['type'] == 'text' && !isset($attributes['value'])) {
                        $errors[] = array('XHTML_MISSING_ATTRIBUTE', $tag, 'value');
                    }
                }
                break;
            case 'select':
                if (isset($attributes['onchange']) && strpos($attributes['onchange'], 'form.submit()') !== false && (get_option('validation') == '0' || !has_js())) {
                    $errors[] = array('WCAG_AUTO_SUBMIT_LIST');
                }
                break;
            case 'table':
                if (isset($attributes['summary']) && ($attributes['summary'] == do_lang('SPREAD_TABLE') || $attributes['summary'] == do_lang('MAP_TABLE'))) {
                    $content = strtolower(substr($OUT, $POS, strpos($OUT, '</table>', $POS) - $POS));
                    // Whilst the </table> found may not be the closing tag to our table, we do know a <th> should occur before any such one (unless it's a really weird table layout)
                    $th_count = substr_count($content, '<th');
                    if ($th_count == 0 && trim($content) != 'x') {
                        $errors[] = array('WCAG_MISSING_TH');
                    } else {
                        if (strpos($content, '<thead') === false) {
                            $tr_count = substr_count($content, '<tr');
                            if ($th_count > $tr_count) {
                                $errors[] = array('WCAG_HD_SPECIAL');
                            }
                        }
                    }
                }
                break;
            case 'thead':
                $array_pos = array_search('table', array_reverse($TAG_STACK));
                if ($array_pos !== false) {
                    $array_pos = count($TAG_STACK) - $array_pos - 1;
                }
                if ($array_pos !== false && isset($ATT_STACK[$array_pos]['summary']) && $ATT_STACK[$array_pos]['summary'] == '') {
                    $errors[] = array('WCAG_BAD_LAYOUT_TABLE');
                }
                break;
            case 'tfoot':
                $array_pos = array_search('table', array_reverse($TAG_STACK));
                if ($array_pos !== false) {
                    $array_pos = count($TAG_STACK) - $array_pos - 1;
                }
                if ($array_pos !== false && isset($ATT_STACK[$array_pos]['summary']) && $ATT_STACK[$array_pos]['summary'] == '') {
                    $errors[] = array('WCAG_BAD_LAYOUT_TABLE');
                }
                break;
            case 'th':
                $array_pos = array_search('table', array_reverse($TAG_STACK));
                if ($array_pos !== false) {
                    $array_pos = count($TAG_STACK) - $array_pos - 1;
                }
                if ($array_pos !== false && isset($ATT_STACK[$array_pos]['summary']) && $ATT_STACK[$array_pos]['summary'] == '') {
                    $errors[] = array('WCAG_BAD_LAYOUT_TABLE');
                }
                if (!isset($attributes['abbr']) && get_value('html5') !== '1') {
                    $content = trim(substr($OUT, $POS, strpos($OUT, '</th>', $POS) - $POS));
                    // This isn't perfect - In theory a th could contain a table itself: but it's not very semantic if it does
                    if (strlen(trim(@html_entity_decode(strip_tags($content), ENT_QUOTES, get_charset()))) > 40) {
                        $errors[] = array('WCAG_TH_TOO_LONG');
                    }
                }
                break;
            case 'a':
                // Handle empty tag check for <a> (couldn't handle with normal case due to complexity)
                if (!isset($attributes['name']) && !isset($attributes['title']) && substr($OUT, $POS, 4) == '</a>') {
                    $errors[] = array('XHTML_EMPTY_TAG', $tag);
                }
                break;
            case 'img':
                if ($GLOBALS['VALIDATION_MANUAL'] && !isset($attributes['width'])) {
                    $errors[] = array('XHTML_WIDTH');
                }
                if (isset($attributes['longdesc']) && !isset($attributes['dlink'])) {
                    $errors[] = array('WCAG_LONGTEXT_DLINK');
                }
                if (isset($attributes['alt']) && isset($attributes['src']) && $attributes['alt'] == $attributes['src']) {
                    $errors[] = array('XHTML_MISSING_ATTRIBUTE', 'img', 'alt');
                }
                if (isset($attributes['alt']) && $attributes['alt'] != '' && (!isset($attributes['width']) || $attributes['width'] != '1') && !isset($attributes['title'])) {
                    $errors[] = array('XHTML_IE_COMPAT_TITLE');
                }
                break;
        }
        /*if (($tag[0]=='h') && (is_numeric(substr($tag,1))))	 Excessive check
        		{
        			global $LAST_HEADING;
        			if ($LAST_HEADING<intval(substr($tag,1))-1) $errors[]=array('WCAG_HEADING_ORDER');
        			$LAST_HEADING=intval(substr($tag,1));
        		}*/
        if (isset($attributes['accesskey'])) {
            $this_href = isset($attributes['href']) ? $attributes['href'] : uniqid('', true);
            if (isset($KEYS_SEEN[$attributes['accesskey']]) && $KEYS_SEEN[$attributes['accesskey']] != $this_href) {
                $errors[] = array('WCAG_ACCESSKEY_UNIQUE');
            }
            $KEYS_SEEN[$attributes['accesskey']] = $this_href;
        }
        if (isset($attributes['tabindex'])) {
            if (in_array($attributes['tabindex'], $TABS_SEEN) && $attributes['tabindex'] != 'x') {
                $last = array_pop($TABS_SEEN);
                if ($last != $attributes['tabindex']) {
                    $errors[] = array('WCAG_TABINDEX_UNIQUE');
                } else {
                    array_push($TABS_SEEN, $last);
                }
            }
            $TABS_SEEN[] = $attributes['tabindex'];
        }
    }
    return $errors;
}
Beispiel #11
0
 /**
  * The UI to edit a menu.
  *
  * @return tempcode		The UI
  */
 function edit_menu()
 {
     if (!has_js()) {
         warn_exit(do_lang_tempcode('MSG_JS_NEEDED'));
     }
     $id = get_param('id', '');
     if ($id == '') {
         $id = get_param('id_new');
     }
     if (substr($id, 0, 1) == '_') {
         warn_exit(do_lang_tempcode('MENU_UNDERSCORE_RESERVED'));
     }
     require_code('type_validation');
     if (!is_alphanumeric($id, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     if ($id == 'zone_menu' && get_option('use_custom_zone_menu') == '0') {
         $config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'THEME'), get_module_zone('admin_config'));
         attach_message(do_lang_tempcode('EDITING_UNUSED_MENU', escape_html($config_url->evaluate())), 'notice');
     }
     $title = get_page_title('_EDIT_MENU', true, array(escape_html($id)));
     $clickable_sections = get_param_integer('clickable_sections', 0) == 1;
     // This is set to '1 if we have a menu type where pop out sections may be clicked on to be loaded. If we do then we make no UI distinction between page nodes and contracted/expanded, so people don't get compelled to choose a URL for everything, it simply becomes an option for them.
     // This will be a templates for branches created dynamically
     $t_id = 'replace_me_with_random';
     $branch = do_template('MENU_EDITOR_BRANCH', array('_GUID' => '59d5c9bebecdac1440112ef8301d7c67', 'CLICKABLE_SECTIONS' => $clickable_sections ? 'true' : 'false', 'I' => $t_id, 'CHILD_BRANCH_TEMPLATE' => '', 'CHILD_BRANCHES' => ''));
     $child_branch_template = do_template('MENU_EDITOR_BRANCH_WRAP', array('_GUID' => 'fb16265f553127b47dfdaf33a420136b', 'DISPLAY' => $clickable_sections ? 'display: block' : 'display: none', 'CLICKABLE_SECTIONS' => $clickable_sections, 'ORDER' => 'replace_me_with_order', 'PARENT' => 'replace_me_with_parent', 'BRANCH_TYPE' => '0', 'NEW_WINDOW' => '0', 'CHECK_PERMS' => '0', 'CAPTION_LONG' => '', 'CAPTION' => '', 'URL' => '', 'PAGE_ONLY' => '', 'THEME_IMG_CODE' => '', 'I' => $t_id, 'BRANCH' => $branch));
     $order = 0;
     $menu_items = $GLOBALS['SITE_DB']->query_select('menu_items', array('*'), array('i_menu' => $id), 'ORDER BY i_parent,i_order');
     $child_branches = $this->menu_branch($id, NULL, $order, $clickable_sections, $menu_items);
     $root_branch = do_template('MENU_EDITOR_BRANCH', array('CLICKABLE_SECTIONS' => $clickable_sections ? 'true' : 'false', 'CHILD_BRANCH_TEMPLATE' => $child_branch_template, 'CHILD_BRANCHES' => $child_branches, 'I' => ''));
     $map = array('page' => '_SELF', 'type' => '_edit', 'id' => $id);
     if (get_param('redirect', '!') != '!') {
         $map['redirect'] = get_param('redirect');
     }
     $post_url = build_url($map, '_SELF');
     $map = array('page' => '_SELF', 'type' => '_edit', 'id' => $id);
     // Actually same as edit URL, just we put this into an empty post form
     if (get_param('redirect', '!') != '!') {
         $map['redirect'] = get_param('redirect');
     }
     $delete_url = build_url($map, '_SELF');
     require_code('form_templates');
     $fields_template = new ocp_tempcode();
     //$fields_template->attach(form_input_line(do_lang_tempcode('CAPTION'),do_lang_tempcode('MENU_ENTRY_CAPTION'),'caption','',true)); This is editable in the tree structure instead
     $fields_template->attach(form_input_line(do_lang_tempcode('LINK'), do_lang_tempcode('MENU_ENTRY_URL'), 'url', '', false));
     $options = array(array(do_lang_tempcode('MENU_ENTRY_NEW_WINDOW'), 'new_window', false, new ocp_tempcode()), array(do_lang_tempcode('MENU_ENTRY_CHECK_PERMS'), 'check_perms', true, do_lang_tempcode('DESCRIPTION_MENU_ENTRY_CHECK_PERMS')));
     $fields_template->attach(form_input_various_ticks($options, '', NULL, do_lang_tempcode('OPTIONS'), false));
     $list = new ocp_tempcode();
     if (!$clickable_sections) {
         $list->attach(form_input_list_entry('page', false, do_lang_tempcode('PAGE')));
     }
     $list->attach(form_input_list_entry('branch_minus', false, do_lang_tempcode('CONTRACTED_BRANCH')));
     $list->attach(form_input_list_entry('branch_plus', false, do_lang_tempcode('EXPANDED_BRANCH')));
     $fields_template->attach(form_input_list(do_lang_tempcode('BRANCH_TYPE'), do_lang_tempcode('MENU_ENTRY_BRANCH'), 'branch_type', $list));
     $fields_template->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields_template->attach(form_input_line(do_lang_tempcode('CAPTION_LONG'), do_lang_tempcode('MENU_ENTRY_CAPTION_LONG'), 'caption_long', '', false));
     $list = new ocp_tempcode();
     $list->attach(form_input_list_entry('', false, do_lang_tempcode('NONE_EM')));
     require_code('themes2');
     $list->attach(nice_get_theme_images(NULL, NULL, false, true, 'menu_items/'));
     $fields_template->attach(form_input_list(do_lang_tempcode('THEME_IMAGE'), do_lang_tempcode('DESCRIPTION_THEME_IMAGE_FOR_MENU_ITEM'), 'theme_img_code', $list, NULL, false, false));
     $fields_template->attach(form_input_line(do_lang_tempcode('RESTRICT_PAGE_VISIBILITY'), do_lang_tempcode('MENU_ENTRY_MATCH_KEYS'), 'match_tags', '', false));
     require_javascript('javascript_ajax');
     require_javascript('javascript_more');
     require_javascript('javascript_tree_list');
     list($warning_details, $ping_url) = handle_conflict_resolution();
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MENU_MANAGEMENT'))));
     $all_menus = array();
     $menu_rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu');
     foreach ($menu_rows as $menu_row) {
         if ($menu_row['i_menu'] != $id) {
             $all_menus[] = $menu_row['i_menu'];
         }
     }
     return do_template('MENU_EDITOR_SCREEN', array('_GUID' => 'd2bc26eaea38f3d5b3221be903ff541e', 'ALL_MENUS' => $all_menus, 'MENU_NAME' => $id, 'DELETE_URL' => $delete_url, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'FIELDS_TEMPLATE' => $fields_template, 'HIGHEST_ORDER' => strval($order), 'URL' => $post_url, 'CHILD_BRANCH_TEMPLATE' => $child_branch_template, 'ROOT_BRANCH' => $root_branch, 'TITLE' => $title));
 }
Beispiel #12
0
/**
 * Get a results table showing security alerts matching WHERE constraints.
 *
 * @param  ?array			WHERE constraints (NULL: none)
 * @return tempcode		The results table
 */
function find_security_alerts($where)
{
    // Alerts
    $start = get_param_integer('alert_start', 0);
    $max = get_param_integer('alert_max', 50);
    $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'ip' => do_lang_tempcode('IP_ADDRESS'));
    $test = explode(' ', get_param('alert_sort', 'date_and_time DESC'));
    if (count($test) == 1) {
        $test[1] = 'DESC';
    }
    list($sortable, $sort_order) = $test;
    if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
        log_hack_attack_and_exit('ORDERBY_HACK');
    }
    global $NON_CANONICAL_PARAMS;
    $NON_CANONICAL_PARAMS[] = 'alert_sort';
    $_fields = array(do_lang_tempcode('FROM'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('IP_ADDRESS'), do_lang_tempcode('REASON'));
    if (has_js()) {
        $_fields[] = new ocp_tempcode();
    }
    $fields_title = results_field_title($_fields, $sortables, 'alert_sort', $sortable . ' ' . $sort_order);
    $max_rows = $GLOBALS['SITE_DB']->query_value('hackattack', 'COUNT(*)', $where);
    $rows = $GLOBALS['SITE_DB']->query_select('hackattack', array('*'), $where, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
    $fields = new ocp_tempcode();
    foreach ($rows as $row) {
        $time = get_timezoned_date($row['date_and_time']);
        $lookup_url = build_url(array('page' => 'admin_lookup', 'param' => $row['ip']), '_SELF');
        $member_url = build_url(array('page' => 'admin_lookup', 'param' => $row['the_user']), '_SELF');
        $full_url = build_url(array('page' => 'admin_security', 'type' => 'view', 'id' => $row['id']), '_SELF');
        $reason = do_lang($row['reason'], $row['reason_param_a'], $row['reason_param_b'], NULL, NULL, false);
        if (is_null($reason)) {
            $reason = $row['reason'];
        }
        $reason = symbol_truncator(array($reason, '50', '1'), 'left');
        $username = $GLOBALS['FORUM_DRIVER']->get_username($row['the_user']);
        if (is_null($username)) {
            $username = do_lang('UNKNOWN');
        }
        $_row = array(hyperlink($member_url, escape_html($username)), hyperlink($full_url, escape_html($time)), hyperlink($lookup_url, escape_html($row['ip'])), $reason);
        if (has_js()) {
            $deletion_tick = do_template('RESULTS_TABLE_TICK', array('ID' => strval($row['id'])));
            $_row[] = $deletion_tick;
        }
        $fields->attach(results_entry($_row));
    }
    return results_table(do_lang_tempcode('SECURITY_ALERTS'), $start, 'alert_start', $max, 'alert_max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'alert_sort');
}
Beispiel #13
0
 /**
  * Standard modular render function for profile tabs edit hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return ?array			A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set)
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('SIGNATURE');
     $order = 40;
     // Actualiser
     $new_signature = post_param('signature', NULL);
     if ($new_signature !== NULL) {
         require_code('ocf_members_action');
         require_code('ocf_members_action2');
         ocf_member_choose_signature($new_signature, $member_id_of);
         require_code('autosave');
         clear_ocp_autosave();
         attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform');
     }
     if ($leave_to_ajax_if_possible) {
         return NULL;
     }
     // UI
     $_signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']);
     $signature = $_signature->is_empty() ? do_lang_tempcode('NONE_EM') : $_signature;
     $_signature_original = get_translated_text($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']);
     $size = ocf_get_member_best_group_property($member_id_of, 'max_sig_length_comcode');
     $javascript = "\n\t\t\tvar form=document.getElementById('signature').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tvar post=form.elements['signature'];\n\t\t\t\t\tif ((!post.value) && (post[1])) post=post[1];\n\t\t\t\t\tif (post.value.length>" . strval($size) . ")\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('SIGNATURE_TOO_BIG')) . "');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t";
     require_code('form_templates');
     $required = false;
     $has_preview = true;
     require_lang('javascript');
     require_javascript('javascript_posting');
     require_javascript('javascript_editing');
     require_javascript('javascript_ajax');
     require_javascript('javascript_swfupload');
     require_css('swfupload');
     require_lang('comcode');
     $tabindex = get_form_field_tabindex();
     $post_comment = do_lang_tempcode('SIGNATURE');
     list($attachments, $attach_size_field) = get_attachments('signature');
     $hidden_fields = new ocp_tempcode();
     $hidden_fields->attach($attach_size_field);
     $continue_url = get_self_url();
     $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
     $emoticon_chooser = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
     $comcode_editor = get_comcode_editor();
     $comcode_editor_small = get_comcode_editor('signature', true);
     $w = has_js() && (browser_matches('wysiwyg') && strpos($_signature_original, '{$,page hint: no_wysiwyg}') === false);
     $class = '';
     global $JAVASCRIPT, $WYSIWYG_ATTACHED;
     if (!$WYSIWYG_ATTACHED) {
         $JAVASCRIPT->attach(do_template('HTML_EDIT'));
     }
     $WYSIWYG_ATTACHED = true;
     @header('Content-type: text/html; charset=' . get_charset());
     if ($w) {
         $class .= ' wysiwyg';
     }
     global $LAX_COMCODE;
     $temp = $LAX_COMCODE;
     $LAX_COMCODE = true;
     $GLOBALS['COMCODE_PARSE_URLS_CHECKED'] = 100;
     // Little hack to stop it checking any URLs
     /*if (is_null($default_parsed)) */
     $default_parsed = comcode_to_tempcode($_signature_original, NULL, false, 60, NULL, NULL, true);
     $LAX_COMCODE = $temp;
     $fields = new ocp_tempcode();
     $fields->attach(do_template('POSTING_FIELD', array('PRETTY_NAME' => do_lang_tempcode('SIGNATURE'), 'DESCRIPTION' => '', 'HIDDEN_FIELDS' => $hidden_fields, 'NAME' => 'signature', 'REQUIRED' => $required, 'TABINDEX_PF' => strval($tabindex), 'COMCODE_EDITOR' => $comcode_editor, 'COMCODE_EDITOR_SMALL' => $comcode_editor_small, 'CLASS' => $class, 'COMCODE_URL' => build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false)), 'EXTRA' => '', 'POST_COMMENT' => $post_comment, 'EMOTICON_CHOOSER' => $emoticon_chooser, 'COMCODE_HELP' => $comcode_help, 'POST' => $_signature_original, 'DEFAULT_PARSED' => $default_parsed, 'CONTINUE_URL' => $continue_url, 'ATTACHMENTS' => $attachments)));
     $text = do_template('OCF_EDIT_SIGNATURE_TAB', array('_GUID' => 'f5f2eb2552c34840c9cf46886422401e', 'SIZE' => integer_format($size), 'SIGNATURE' => $signature, 'TITLE' => $title));
     return array($title, $fields, $text, $javascript, $order);
 }
Beispiel #14
0
/**
 * Find whether a particular feature is available to ocPortal (e.g. it's an addon).
 *
 * @param  ID_TEXT		Feature name
 * @return boolean		Whether it is
 */
function has_feature($dependency)
{
    $dependency = str_replace(' ', '', strtolower(preg_replace('# (enabled|needed|required)$#', '', $dependency)));
    if ($dependency == 'yes') {
        return true;
    }
    // Buggy addon definition
    $remapping = array('chatrooms' => 'chat', 'side_stats' => 'stats_block');
    if (array_key_exists($dependency, $remapping)) {
        $dependency = $remapping[$dependency];
    }
    // Non-bundled addon
    $test = $GLOBALS['SITE_DB']->query_value_null_ok('addons', 'addon_name', array('addon_name' => $dependency));
    if (!is_null($test)) {
        return true;
    }
    // Bundled/new-style addon
    if (file_exists(get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . $dependency . '.php')) {
        return true;
    }
    if (file_exists(get_file_base() . '/sources/hooks/systems/addon_registry/' . $dependency . '.php')) {
        return true;
    }
    // Some other features
    if ($dependency == 'javascript' && has_js()) {
        return true;
    }
    if ($dependency == 'cron' && cron_installed()) {
        return true;
    }
    if ($dependency == 'ocf' && get_forum_type() == 'ocf') {
        return true;
    }
    if ($dependency == 'gd' && get_option('is_on_gd') == '1' && function_exists('imagecreatefromstring')) {
        return true;
    }
    if ($dependency == 'adobeflash') {
        return true;
    }
    if (substr($dependency, 0, 3) == 'php') {
        $phpv = phpversion();
        if (version_compare(substr($phpv, 0, strlen(substr($dependency, 3))), substr($dependency, 3), '>=')) {
            return true;
        }
    }
    // ---
    // Try plural form
    if (substr($dependency, -1) != 's') {
        return has_feature($dependency . 's');
    }
    return false;
}
Beispiel #15
0
/**
 * Get the tempcode for a date input.
 *
 * @param  mixed			A human intelligible name for this input field
 * @param  mixed			A description for this input field
 * @param  ID_TEXT		The parameter name stub for this input field (it's actually a composite field, read in by passing this stub to post_param_date)
 * @param  boolean		Whether this is a required field
 * @param  boolean		Whether this field is empty by default
 * @param  boolean		Whether to input time for this field also
 * @param  ?mixed			The default timestamp to use (either TIME or array of time components) (NULL: now)
 * @param  ?integer		The number of years to allow selection from (all into the future, as this field type is not meant for inputting past dates) (NULL: no limit)
 * @param  ?integer		The year to start from (NULL: this year)
 * @param  ?integer		The tab index of the field (NULL: not specified)
 * @param  ?boolean		Whether this is rendered in pink as a required field (NULL: depend on $null_ok)
 * @param  boolean		Whether to input date for this field (if false, will just do time)
 * @param  ?ID_TEXT		Timezone to input in (NULL: current user's timezone)
 * @param  boolean		Convert $default_time to $timezone
 * @return tempcode		The input field
 */
function form_input_date($pretty_name, $description, $stub, $null_ok, $null_default, $do_time, $default_time = NULL, $total_years_to_show = 10, $year_start = NULL, $tabindex = NULL, $required = NULL, $do_date = true, $timezone = NULL, $handle_timezone = true)
{
    if (is_null($required)) {
        $required = !$null_ok;
    }
    $tabindex = get_form_field_tabindex($tabindex);
    require_lang('dates');
    require_javascript('javascript_multi');
    require_javascript('javascript_yahoo');
    require_javascript('javascript_yahoo_events');
    require_javascript('javascript_date_chooser');
    require_css('date_chooser');
    if (is_null($year_start)) {
        $year_start = intval(date('Y'));
    }
    $untuned_year_start = $year_start;
    // The $year_start may go down if our default date requires it, but we need to know what our $total_years_to_show should really be relative to
    $default_minute = mixed();
    $default_hour = mixed();
    $default_month = mixed();
    $default_day = mixed();
    $default_year = mixed();
    if (is_array($default_time) && $default_time[4] < 1970 && @strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) != '1963') {
        list($default_minute, $default_hour, $default_month, $default_day, $default_year) = $default_time;
        if (is_null($default_minute)) {
            $default_minute = 0;
        }
        if (is_null($default_hour)) {
            $default_hour = 0;
        }
    } else {
        if (is_array($default_time)) {
            if (is_null($default_time[4])) {
                $default_time = NULL;
            } else {
                list($default_minute, $default_hour, $default_month, $default_day, $default_year) = $default_time;
                $default_time = mktime($default_hour, $default_minute, 0, $default_month, $default_day, $default_year);
            }
        }
        $_default_time = filter_form_field_default($stub, is_null($default_time) ? '' : strval($default_time));
        $default_time = $_default_time == '' ? NULL : intval($_default_time);
        if (!is_null($default_time) && $handle_timezone) {
            if (is_null($timezone)) {
                $timezone = get_users_timezone();
            }
            $default_time = tz_time($default_time, $timezone);
        }
        $default_minute = is_null($default_time) ? NULL : intval(date('i', $default_time));
        $default_hour = is_null($default_time) ? NULL : intval(date('H', $default_time));
        $default_month = is_null($default_time) ? NULL : intval(date('n', $default_time));
        $default_day = is_null($default_time) ? NULL : intval(date('j', $default_time));
        $default_year = is_null($default_time) ? NULL : intval(date('Y', $default_time));
    }
    if (is_integer($default_year) && $default_year < $year_start) {
        $year_start = $default_year;
    }
    ob_start();
    for ($minute = 0; $minute < 60; $minute++) {
        $_minute = strval($minute);
        $temp = form_input_list_entry($_minute, $minute === $default_minute, $minute < 10 ? str_pad($_minute, 2, '0', STR_PAD_LEFT) : $_minute);
        $temp->evaluate_echo();
    }
    $minutes = ob_get_contents();
    ob_end_clean();
    ob_start();
    for ($hour = 0; $hour < 24; $hour++) {
        $text_hour = locale_filter(gmdate(do_lang('time_hour'), intval($hour * 60 * 60)));
        $temp = form_input_list_entry(strval($hour), $hour === $default_hour, $text_hour);
        $temp->evaluate_echo();
    }
    $hours = ob_get_contents();
    ob_end_clean();
    $time = $do_time ? do_template('FORM_SCREEN_INPUT_TIME', array('NULL_OK' => $null_ok, 'DISABLED' => $null_default && has_js(), 'TABINDEX' => strval($tabindex), 'MINUTES' => $minutes, 'HOURS' => $hours, 'STUB' => $stub)) : new ocp_tempcode();
    if (!$do_date) {
        return _form_input($stub, $pretty_name, $description, $time, $required, false, $tabindex, false, true);
    }
    $null = $null_ok ? do_template('FORM_SCREEN_INPUT_DATE_NULL', array('_GUID' => '22859d15f1b295b08036e1d0308d371a', 'TICKED' => !$null_default, 'TABINDEX' => strval($tabindex), 'STUB' => $stub)) : new ocp_tempcode();
    ob_start();
    for ($i = 1; $i <= 31; $i++) {
        $temp = form_input_list_entry(strval($i), $i === $default_day);
        $temp->evaluate_echo();
    }
    $days = ob_get_contents();
    ob_end_clean();
    ob_start();
    for ($i = 1; $i <= 12; $i++) {
        switch ($i) {
            case 1:
                $month_text = do_lang_tempcode('JANUARY');
                break;
            case 2:
                $month_text = do_lang_tempcode('FEBRUARY');
                break;
            case 3:
                $month_text = do_lang_tempcode('MARCH');
                break;
            case 4:
                $month_text = do_lang_tempcode('APRIL');
                break;
            case 5:
                $month_text = do_lang_tempcode('MAY');
                break;
            case 6:
                $month_text = do_lang_tempcode('JUNE');
                break;
            case 7:
                $month_text = do_lang_tempcode('JULY');
                break;
            case 8:
                $month_text = do_lang_tempcode('AUGUST');
                break;
            case 9:
                $month_text = do_lang_tempcode('SEPTEMBER');
                break;
            case 10:
                $month_text = do_lang_tempcode('OCTOBER');
                break;
            case 11:
                $month_text = do_lang_tempcode('NOVEMBER');
                break;
            case 12:
                $month_text = do_lang_tempcode('DECEMBER');
                break;
        }
        $temp = form_input_list_entry(strval($i), $i === $default_month, $month_text);
        $temp->evaluate_echo();
    }
    $months = ob_get_contents();
    ob_end_clean();
    ob_start();
    if (!is_null($total_years_to_show) && $total_years_to_show < 0) {
        $yt = $year_start + $total_years_to_show;
        for ($i = max($untuned_year_start, $year_start); $i >= $yt; $i--) {
            $temp = form_input_list_entry(strval($i), $i === $default_year);
            $temp->evaluate_echo();
        }
    } else {
        if (is_null($total_years_to_show)) {
            $yt = max($untuned_year_start, $year_start) + 5;
        } else {
            $yt = max($untuned_year_start, $year_start) + $total_years_to_show;
        }
        for ($i = $year_start; $i <= $yt; $i++) {
            $temp = form_input_list_entry(strval($i), $i === $default_year);
            $temp->evaluate_echo();
        }
    }
    $years = ob_get_contents();
    ob_end_clean();
    $input = do_template('FORM_SCREEN_INPUT_DATE', array('_GUID' => '5ace58dd0f540f70fb3bd440fb02a430', 'NULL_OK' => $null_ok, 'DISABLED' => $null_default, 'TABINDEX' => strval($tabindex), 'YEARS' => $years, 'MONTHS' => $months, 'DAYS' => $days, 'STUB' => $stub, 'NULL' => $null, 'TIME' => $time, 'UNLIMITED' => is_null($total_years_to_show)));
    return _form_input($stub, $pretty_name, $description, $input, $required, false, $tabindex, false, true);
}
Beispiel #16
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!has_js()) {
         warn_exit(do_lang_tempcode('MSG_JS_NEEDED'));
     }
     // What action are we going to do?
     $type = get_param('type', 'misc');
     if (function_exists('set_time_limit')) {
         @set_time_limit(200);
     }
     require_javascript('javascript_xmpp_prototype');
     //require_javascript('javascript_xmpp_extjs2');
     require_javascript('javascript_xmpp_dom-all');
     require_javascript('javascript_xmpp_crypto');
     require_javascript('javascript_xmpp_xmpp4js');
     require_javascript('javascript_ajax');
     require_javascript('javascript_chat');
     require_javascript('javascript_sound');
     require_javascript('javascript_editing');
     require_javascript('javascript_validation');
     require_lang('comcode');
     require_lang('chat');
     require_code('chat');
     require_css('chat');
     if ($type == 'room') {
         return $this->chat_room();
     }
     if ($type == 'options') {
         return $this->chat_options();
     }
     if ($type == 'private') {
         return $this->chat_private();
     }
     if ($type == '_private') {
         return $this->_chat_private();
     }
     if ($type == 'download_logs') {
         return $this->chat_download_logs();
     }
     if ($type == '_download_logs') {
         return $this->_chat_download_logs();
     }
     if ($type == 'misc') {
         return $this->chat_lobby();
     }
     if ($type == 'blocking_interface') {
         return $this->blocking_interface();
     }
     if ($type == 'blocking_set') {
         return $this->blocking_set();
     }
     if ($type == 'blocking_add') {
         return $this->blocking_add();
     }
     if ($type == 'blocking_remove') {
         return $this->blocking_remove();
     }
     if ($type == 'buddy_add') {
         return $this->buddy_add();
     }
     if ($type == 'buddy_remove') {
         return $this->buddy_remove();
     }
     if ($type == 'buddies_list') {
         return $this->buddies_list();
     }
     if ($type == 'set_effects') {
         return $this->set_effects();
     }
     if ($type == '_set_effects') {
         return $this->_set_effects();
     }
     return new ocp_tempcode();
 }
Beispiel #17
0
 /**
  * The UI for the zone editor.
  *
  * @return tempcode		The UI
  */
 function _editor()
 {
     $id = get_param('id', '');
     // '' needed for short URLs
     if ($id == '/') {
         $id = '';
     }
     $GLOBALS['EXTRA_HEAD']->attach(make_string_tempcode('<base target="_blank" />'));
     $nice_zone_name = $id == '' ? do_lang('_WELCOME') : $id;
     $title = get_page_title('_ZONE_EDITOR', true, array(escape_html($nice_zone_name)));
     $lang = choose_language($title, true);
     if (is_object($lang)) {
         return $lang;
     }
     require_javascript('javascript_zone_editor');
     require_javascript('javascript_ajax');
     require_javascript('javascript_more');
     require_javascript('javascript_posting');
     require_javascript('javascript_editing');
     require_javascript('javascript_validation');
     require_code('form_templates');
     require_lang('comcode');
     if (!has_js()) {
         // Send them to the page permissions screen
         $url = build_url(array('page' => '_SELF', 'type' => 'edit'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => '20ed5fa100b87756a77c48988ef856ae', 'URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_ZONE_EDITOR')));
     }
     // After completion prep/relay
     $_default_redirect = build_url(array('page' => ''), $id);
     $default_redirect = $_default_redirect->evaluate();
     $post_url = build_url(array('page' => '_SELF', 'type' => '__editor', 'lang' => $lang, 'redirect' => get_param('redirect', $default_redirect), 'id' => $id), '_SELF');
     // Zone editing stuff
     $rows = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $rows[0];
     $header_text = get_translated_text($row['zone_header_text'], NULL, $lang);
     $default_page = $row['zone_default_page'];
     list($fields, , ) = $this->get_form_fields(true, get_translated_text($row['zone_title'], NULL, $lang), $default_page, $header_text, $row['zone_theme'], $row['zone_wide'], $row['zone_require_session'], $row['zone_displayed_in_menu'], $id);
     // Page editing stuff
     $editor = array();
     foreach (array('panel_left', $default_page, 'panel_right') as $i => $for) {
         $page_info = _request_page($for, $id, NULL, $lang);
         if ($page_info === false) {
             $page_info = array('COMCODE_CUSTOM', $id, $for, $lang);
         }
         $is_comcode = false;
         $redirecting_to = NULL;
         $current_for = $for;
         $pure = false;
         switch ($page_info[0]) {
             case 'COMCODE_CUSTOM_PURE':
                 $pure = true;
             case 'COMCODE':
             case 'COMCODE_CUSTOM':
                 $is_comcode = true;
                 $type = do_lang_tempcode('COMCODE_PAGE');
                 break;
             case 'HTML':
             case 'HTML_CUSTOM':
                 $type = protect_from_escaping(escape_html('HTML'));
                 break;
             case 'MODULES':
             case 'MODULES_CUSTOM':
                 $type = do_lang_tempcode('MODULE');
                 break;
             case 'MINIMODULES':
             case 'MINIMODULES_CUSTOM':
                 $type = do_lang_tempcode('MINIMODULE');
                 break;
             case 'REDIRECT':
                 $type = do_lang_tempcode('REDIRECT_PAGE_TO', escape_html($page_info[1]['r_to_zone']), escape_html($page_info[1]['r_to_page']));
                 $redirecting_to = $page_info[1]['r_to_zone'];
                 $current_for = $page_info[1]['r_to_page'];
                 $page_info = _request_page($current_for, $redirecting_to, NULL, $lang);
                 if ($page_info !== false) {
                     switch ($page_info[0]) {
                         case 'COMCODE_CUSTOM_PURE':
                             $pure = true;
                         case 'COMCODE':
                         case 'COMCODE_CUSTOM':
                             $is_comcode = true;
                             break;
                     }
                 }
                 break;
             default:
                 $type = do_lang_tempcode('UNKNOWN');
                 break;
         }
         $class = '';
         $w = false;
         $current_zone = is_null($redirecting_to) ? $id : $redirecting_to;
         $default_parsed = NULL;
         if ($is_comcode) {
             $fullpath = zone_black_magic_filterer(($page_info[0] == 'comcode' || $pure ? get_file_base() : get_custom_file_base()) . '/' . $current_zone . '/pages/' . strtolower($page_info[0]) . '/' . $lang . '/' . $current_for . '.txt');
             if (!file_exists($fullpath)) {
                 $fullpath = zone_black_magic_filterer(($page_info[0] == 'comcode' || $pure ? get_file_base() : get_custom_file_base()) . '/' . $current_zone . '/pages/' . strtolower($page_info[0]) . '/' . get_site_default_lang() . '/' . $current_for . '.txt');
             }
             if (file_exists($fullpath)) {
                 $comcode = file_get_contents($fullpath, FILE_TEXT);
                 $default_parsed = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true);
             } else {
                 $comcode = '';
             }
             $edit_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $current_zone . ':' . $current_for), get_module_zone('cms_comcode_pages'));
             // WYSIWYG?
             require_javascript('javascript_editing');
             $w = has_js() && (browser_matches('wysiwyg') && strpos($comcode, '{$,page hint: no_wysiwyg}') === false);
             global $JAVASCRIPT, $WYSIWYG_ATTACHED;
             if (!$WYSIWYG_ATTACHED) {
                 $JAVASCRIPT->attach(do_template('HTML_EDIT'));
             }
             $WYSIWYG_ATTACHED = true;
             if ($w) {
                 @header('Content-type: text/html; charset=' . get_charset());
                 $class .= ' wysiwyg';
             }
         } else {
             $comcode = NULL;
             $edit_url = new ocp_tempcode();
         }
         $field_name = 'edit_' . $for . '_textarea';
         if ($i == 1) {
             $settings = $fields;
             $comcode_editor = get_comcode_editor($field_name);
         } else {
             $settings = NULL;
             $button = 'block';
             $comcode_editor = new ocp_tempcode();
             $comcode_editor->attach(do_template('COMCODE_EDITOR_BUTTON', array('_GUID' => '0acc5dcf299325d0cf55871923148a54', 'DIVIDER' => false, 'FIELD_NAME' => $field_name, 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button)));
             $button = 'comcode';
             $comcode_editor->attach(do_template('COMCODE_EDITOR_BUTTON', array('_GUID' => '1acc5dcf299325d0cf55871923148a54', 'DIVIDER' => false, 'FIELD_NAME' => $field_name, 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button)));
         }
         global $TEMPCODE_SETGET;
         if ($for == $default_page) {
             $TEMPCODE_SETGET['in_panel'] = '0';
         } else {
             $TEMPCODE_SETGET['in_panel'] = '1';
         }
         $preview = substr($page_info[0], 0, 6) == 'MODULE' ? NULL : request_page($for, false, $id, NULL, true);
         if (!is_null($preview)) {
             $_preview = $preview->evaluate();
             if (!$is_comcode || strpos($comcode, '<') !== false) {
                 require_code('xhtml');
                 $_preview = xhtmlise_html($_preview, true);
                 // Fix potential errors by passing it through our XHTML fixer functions
             } else {
                 $new = $_preview;
                 if (preg_replace('#\\s+#', '', $new) != preg_replace('#\\s+#', '', $_preview)) {
                     $_preview = $new;
                     $_preview .= do_lang('BROKEN_XHTML_FIXED');
                 }
             }
         } else {
             $_preview = NULL;
         }
         $is_panel = substr($for, 0, 6) == 'panel_';
         require_code('zones3');
         $zone_list = $for == $current_for ? nice_get_zones($redirecting_to, array($id)) : new ocp_tempcode();
         $editor[$for] = static_evaluate_tempcode(do_template('ZONE_EDITOR_PANEL', array('_GUID' => 'f32ac84fe18b90497acd4afa27698bf0', 'DEFAULT_PARSED' => $default_parsed, 'CLASS' => $class, 'CURRENT_ZONE' => $current_zone, 'ZONES' => $zone_list, 'COMCODE' => $comcode, 'PREVIEW' => $_preview, 'ZONE' => $id, 'ID' => $for, 'IS_PANEL' => $is_panel, 'TYPE' => $type, 'EDIT_URL' => $edit_url, 'SETTINGS' => $settings, 'COMCODE_EDITOR' => $comcode_editor)));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:editor', do_lang_tempcode('CHOOSE'))));
     breadcrumb_set_self($nice_zone_name);
     list($warning_details, $ping_url) = handle_conflict_resolution($id);
     $GLOBALS['HELPER_PANEL_PIC'] = '';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = '';
     $GLOBALS['HELPER_PANEL_TEXT'] = '';
     return do_template('ZONE_EDITOR_SCREEN', array('_GUID' => '3cb1aab6b16444484e82d22f2c8f1e9a', 'ID' => $id, 'LANG' => $lang, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'LEFT_EDITOR' => $editor['panel_left'], 'RIGHT_EDITOR' => $editor['panel_right'], 'MIDDLE_EDITOR' => $editor[$default_page]));
 }
Beispiel #18
0
/**
 * Get the parsed contents of a comcode page.
 *
 * @param  PATH			The relative (to ocPortal's base directory) path to the page (e.g. pages/comcode/EN/start.txt)
 * @param  ID_TEXT		The zone the page is being loaded from
 * @param  ID_TEXT		The codename of the page
 * @param  ?PATH			The file base to load from (NULL: standard)
 * @param  boolean		Whether the page is being included from another
 * @return tempcode		The page
 */
function load_comcode_page($string, $zone, $codename, $file_base = NULL, $being_included = false)
{
    if ($file_base === NULL) {
        $file_base = get_file_base();
    }
    if (!$being_included) {
        $GLOBALS['TITLE_CALLED'] = true;
    }
    $is_panel = substr($codename, 0, 6) == 'panel_' || strpos($codename, 'panel_') !== false && get_param_integer('keep_theme_test', 0) == 1;
    if ($zone == '' && $codename == '404') {
        global $EXTRA_HEAD;
        $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
        // XHTMLXHTML
        $GLOBALS['HTTP_STATUS_CODE'] = '404';
        if (!headers_sent()) {
            if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
                header('HTTP/1.0 404 Not Found');
            }
        }
    }
    if (($is_panel || $codename[0] == '_') && get_page_name() == $codename) {
        global $EXTRA_HEAD;
        $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
        // XHTMLXHTML
    }
    if ($zone == 'adminzone') {
        require_code('site_adminzone');
        adminzone_special_cases($codename);
    }
    if ($codename == 'sitemap') {
        $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=comcode_pages&filter=' . $zone;
    }
    global $PAGE_STRING, $COMCODE_PARSE_TITLE, $LAST_COMCODE_PARSED_TITLE;
    $COMCODE_PARSE_TITLE = NULL;
    if ($PAGE_STRING === NULL && !$being_included && !$is_panel) {
        $PAGE_STRING = $string;
    }
    $new_comcode_page_row = array('the_zone' => $zone, 'the_page' => $codename, 'p_parent_page' => '', 'p_validated' => 1, 'p_edit_date' => NULL, 'p_add_date' => NULL, 'p_submitter' => NULL, 'p_show_as_edit' => 0);
    if ((get_option('is_on_comcode_page_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1 || get_param_integer('cache_blocks', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache_blocks', NULL) !== 0 && get_param_integer('cache', NULL) !== 0 && get_param_integer('keep_print', 0) == 0) {
        global $SITE_INFO;
        $support_smart_decaching = !isset($SITE_INFO['disable_smart_decaching']) || $SITE_INFO['disable_smart_decaching'] == '0';
        if (is_browser_decacheing()) {
            $comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index', 'cc_page_title'), array('the_page' => $codename, 'the_zone' => $zone, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme()), '', 1, 0, false, array());
            if (array_key_exists(0, $comcode_page)) {
                if ($comcode_page[0]['string_index'] !== NULL) {
                    delete_lang($comcode_page[0]['string_index']);
                }
                $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $codename, 'the_zone' => $zone));
            }
        }
        $theme = $GLOBALS['FORUM_DRIVER']->get_theme();
        if ($GLOBALS['MEM_CACHE'] !== NULL) {
            if ($support_smart_decaching) {
                $mtime = filemtime($file_base . '/' . $string);
                if ($mtime > time()) {
                    $mtime = time();
                }
                // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes.
                $pcache = persistant_cache_get(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang()), $mtime);
            } else {
                $pcache = persistant_cache_get(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang()));
            }
        } else {
            $pcache = NULL;
        }
        if ($pcache === NULL) {
            $comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages a JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'comcode_pages b ON (a.the_page=b.the_page AND a.the_zone=b.the_zone)', array('*'), array('a.the_page' => $codename, 'a.the_zone' => $zone, 'the_theme' => $theme), '', 1, NULL, false, array('string_index', 'cc_page_title'));
            if (array_key_exists(0, $comcode_page)) {
                if ($support_smart_decaching) {
                    $mtime = filemtime($file_base . '/' . $string);
                    if ($mtime > time()) {
                        $mtime = time();
                    }
                    // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes.
                }
                if (!$support_smart_decaching || ($comcode_page[0]['p_edit_date'] !== NULL && $comcode_page[0]['p_edit_date'] >= $mtime || $comcode_page[0]['p_edit_date'] === NULL && $comcode_page[0]['p_add_date'] !== NULL && $comcode_page[0]['p_add_date'] >= $mtime)) {
                    $comcode_page_row = $comcode_page[0];
                    $db_set = get_translated_tempcode($comcode_page[0]['string_index'], NULL, user_lang(), true, true, true);
                    unset($GLOBALS['RECORDED_LANG_STRINGS_CONTENT'][$comcode_page[0]['string_index']]);
                } else {
                    $mtime = filemtime($file_base . '/' . $string);
                    if ($mtime > time()) {
                        $mtime = time();
                    }
                    // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes.
                    $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_edit_date' => $mtime), array('the_page' => $codename, 'the_zone' => $zone), '', 1);
                    $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $codename));
                    delete_lang($comcode_page[0]['string_index']);
                    $db_set = NULL;
                    $comcode_page_row = NULL;
                }
            } else {
                $db_set = NULL;
                $comcode_page_row = NULL;
            }
            if ($db_set !== NULL) {
                $index = $comcode_page[0]['string_index'];
                $title_to_use = $comcode_page[0]['cc_page_title'];
                if ($title_to_use !== NULL) {
                    $title_to_use = get_translated_text($title_to_use, NULL, NULL, true);
                    if ($title_to_use === NULL) {
                        $title_to_use = $codename;
                    }
                }
                $html = $db_set;
            } else {
                $comcode_page = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_page' => $codename, 'the_zone' => $zone), '', 1);
                if (array_key_exists(0, $comcode_page)) {
                    $comcode_page_row = $comcode_page[0];
                }
                require_code('site2');
                $new_comcode_page_row['p_add_date'] = filectime($file_base . '/' . $string);
                list($html, $title_to_use, $comcode_page_row) = _load_comcode_page_not_cached($string, $zone, $codename, $file_base, $comcode_page_row, $new_comcode_page_row, $being_included);
            }
            persistant_cache_set(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang()), array($html, $title_to_use, $comcode_page_row));
        } else {
            list($html, $title_to_use, $comcode_page_row) = $pcache;
        }
    } else {
        require_code('site2');
        $new_comcode_page_row['p_add_date'] = filectime($file_base . '/' . $string);
        list($html, $comcode_page_row, $title_to_use) = _load_comcode_page_cache_off($string, $zone, $codename, $file_base, $new_comcode_page_row, $being_included);
    }
    $filtered_title_to_use = mixed();
    if (!$is_panel && !$being_included) {
        if ($title_to_use !== NULL && $title_to_use != '') {
            get_page_title($title_to_use, false);
            // Little hack - this gets shift encoded, but shift encoding can't survive a tempcode cache. This will force it to reshift. It'll also make sure DISPLAYED_TITLE gets set.
            $filtered_title_to_use = @html_entity_decode(strip_tags($title_to_use), ENT_QUOTES, get_charset());
        }
        seo_meta_load_for('comcode_page', $zone . ':' . $codename, $filtered_title_to_use);
    }
    $LAST_COMCODE_PARSED_TITLE = $title_to_use;
    if ($html->is_definitely_empty() && $being_included) {
        return $html;
    }
    if (has_actual_page_access(get_member(), 'cms_comcode_pages', NULL, NULL, $comcode_page_row['p_submitter'] == get_member() && !is_guest() ? 'edit_own_highrange_content' : 'edit_highrange_content')) {
        $redirect = get_self_url(true, false, array('redirect' => NULL, 'redirected' => NULL));
        if (($codename == 'panel_left' || $codename == 'panel_right') && has_js() && has_actual_page_access(get_member(), 'admin_zones')) {
            $edit_url = build_url(array('page' => 'admin_zones', 'type' => '_editor', 'id' => get_zone_name(), 'redirect' => $redirect, 'wide' => 1), get_module_zone('admin_zones'));
        } else {
            $edit_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $zone . ':' . $codename, 'redirect' => $redirect), get_module_zone('cms_comcode_pages'));
        }
        $add_child_url = get_option('is_on_comcode_page_children') == '1' ? build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'parent_page' => $codename, 'page_link' => $zone . ':'), get_module_zone('cms_comcode_pages')) : new ocp_tempcode();
    } else {
        $edit_url = new ocp_tempcode();
        $add_child_url = new ocp_tempcode();
    }
    $warning_details = new ocp_tempcode();
    if ($comcode_page_row['p_validated'] !== NULL && $comcode_page_row['p_validated'] == 0) {
        require_code('site2');
        $warning_details = get_page_warning_details($zone, $codename, $edit_url);
    }
    if (!$is_panel && $title_to_use !== NULL && !$being_included) {
        global $PT_PAIR_CACHE_CP;
        $PT_PAIR_CACHE_CP[$codename]['cc_page_title'] = $title_to_use === NULL ? do_lang_tempcode('NA_EM') : make_string_tempcode($title_to_use);
        $PT_PAIR_CACHE_CP[$codename]['p_parent_page'] = $comcode_page_row['p_parent_page'];
        $comcode_breadcrumbs = comcode_breadcrumbs($codename, $zone, get_param('root', ''), $comcode_page_row['p_parent_page'] == '' || !has_specific_permission(get_member(), 'open_virtual_roots'));
        breadcrumb_add_segment($comcode_breadcrumbs);
        $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $comcode_page_row['p_add_date']), 'creator' => is_guest($comcode_page_row['p_submitter']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($comcode_page_row['p_submitter']), 'publisher' => '', 'modified' => $comcode_page_row['p_edit_date'] === NULL ? '' : date('Y-m-d', $comcode_page_row['p_edit_date']), 'type' => 'Comcode page', 'title' => $title_to_use, 'identifier' => $zone . ':' . $codename, 'description' => '');
    }
    if ($html->is_definitely_empty() && $is_panel) {
        return $html;
    }
    global $SCREEN_TEMPLATE_CALLED;
    $st = $SCREEN_TEMPLATE_CALLED;
    $ret = do_template('COMCODE_PAGE_SCREEN', array('_GUID' => '0fc4fe4f27e54aaaa2b7e4848c02bacb', 'IS_PANEL' => $is_panel, 'BEING_INCLUDED' => $being_included, 'SUBMITTER' => strval($comcode_page_row['p_submitter']), 'TAGS' => get_loaded_tags('comcode_pages'), 'WARNING_DETAILS' => $warning_details, 'EDIT_DATE_RAW' => $comcode_page_row['p_edit_date'] === NULL ? '' : strval($comcode_page_row['p_edit_date']), 'SHOW_AS_EDIT' => $comcode_page_row['p_show_as_edit'] == 1, 'CONTENT' => $html, 'EDIT_URL' => $edit_url, 'ADD_CHILD_URL' => $add_child_url, 'NAME' => $codename));
    if ($is_panel || $being_included) {
        $SCREEN_TEMPLATE_CALLED = $st;
    }
    return $ret;
}
Beispiel #19
0
 /**
  * The main user interface for moderating a chat room.
  *
  * @return tempcode	The UI.
  */
 function moderate_chat_room()
 {
     $title = get_page_title('CHAT_MOD_PANEL');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE'))));
     $room_id = get_param_integer('id');
     check_chatroom_access($room_id);
     $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1);
     if (!array_key_exists(0, $room_details)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $room_details[0];
     $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $room_id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms');
     if (!$has_mod_access) {
         access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content');
     }
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'user_id' => do_lang_tempcode('MEMBER'));
     $test = explode(' ', get_param('sort', 'date_and_time DESC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sort';
     $max_rows = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)', array('room_id' => $room_id));
     $rows = $GLOBALS['SITE_DB']->query_select('chat_messages', array('*'), array('room_id' => $room_id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     $fields = new ocp_tempcode();
     require_code('templates_results_table');
     $array = array(do_lang_tempcode('MEMBER'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('MESSAGE'));
     if (has_js()) {
         $array[] = do_lang_tempcode('DELETE');
     }
     $fields_title = results_field_title($array, $sortables, 'sort', $sortable . ' ' . $sort_order);
     foreach ($rows as $myrow) {
         $url = build_url(array('page' => '_SELF', 'type' => 'ed', 'room_id' => $room_id, 'id' => $myrow['id']), '_SELF');
         $username = $GLOBALS['FORUM_DRIVER']->get_username($myrow['user_id']);
         if (is_null($username)) {
             $username = '';
         }
         //do_lang('UNKNOWN');
         $message = get_translated_tempcode($myrow['the_message']);
         $link_time = hyperlink($url, escape_html(get_timezoned_date($myrow['date_and_time'])));
         $_row = array($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($GLOBALS['FORUM_DRIVER']->get_member_from_username($username), false, $username), escape_html($link_time), $message);
         if (has_js()) {
             $deletion_tick = do_template('RESULTS_TABLE_TICK', array('ID' => strval($myrow['id'])));
             $_row[] = $deletion_tick;
         }
         $fields->attach(results_entry($_row));
     }
     if ($fields->is_empty()) {
         if ($start != 0) {
             $_GET['start'] = strval(max(0, $start - $max));
             return $this->moderate_chat_room();
         }
         inform_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $content = results_table(do_lang_tempcode('MESSAGES'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     $mod_link = hyperlink(build_url(array('page' => '_SELF', 'type' => 'delete', 'stage' => 0, 'id' => $room_id), '_SELF'), do_lang_tempcode('DELETE_ALL_MESSAGES'));
     $view_link = hyperlink(build_url(array('page' => 'chat', 'type' => 'room', 'id' => $room_id), get_module_zone('chat')), do_lang_tempcode('VIEW'));
     $logs_link = hyperlink(build_url(array('page' => 'chat', 'type' => 'download_logs', 'id' => $room_id), get_module_zone('chat')), do_lang_tempcode('CHAT_DOWNLOAD_LOGS'));
     $links = array($mod_link, $view_link, $logs_link);
     $delete_url = build_url(array('page' => '_SELF', 'type' => 'mass_delete', 'room_id' => $room_id, 'start' => $start, 'max' => $max), '_SELF');
     return do_template('CHAT_MODERATE_SCREEN', array('_GUID' => '940de7e8c9a0ac3c575892887c7ef3c0', 'URL' => $delete_url, 'TITLE' => $title, 'INTRODUCTION' => '', 'CONTENT' => $content, 'LINKS' => $links));
 }
Beispiel #20
0
 /**
  * The actualiser to move a page.
  *
  * @return tempcode		The UI
  */
 function _move()
 {
     $title = get_page_title('MOVE_PAGES');
     if (get_file_base() != get_custom_file_base()) {
         warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     }
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/move';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure';
     $zone = post_param('zone', NULL);
     if (is_null($zone)) {
         $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true);
         $hidden = build_keep_form_fields('', true);
         return do_template('YESNO_SCREEN', array('_GUID' => 'c6e872cc62bdc7cf1c5157fbfdb2dfd6', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE'), 'URL' => $post_url, 'HIDDEN' => $hidden));
     }
     $new_zone = post_param('destination_zone', '');
     if (substr($new_zone, -1) == ':') {
         $new_zone = substr($new_zone, 0, strlen($new_zone) - 1);
     }
     //$pages=find_all_pages_wrap($zone);
     $pages = array();
     require_code('site');
     foreach ($_POST as $key => $val) {
         if (substr($key, 0, 6) == 'page__' && $val === '1') {
             $page = substr($key, 6);
             $page_details = _request_page($page, $zone, NULL, NULL, true);
             if ($page_details === false) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $pages[$page] = strtolower($page_details[0]);
             if (array_key_exists(3, $page_details)) {
                 $pages[$page] .= '/' . $page_details[3];
             }
         }
     }
     $afm_needed = false;
     foreach ($pages as $page => $type) {
         if (post_param_integer('page__' . $page, 0) == 1) {
             if ($type != 'comcode_custom') {
                 $afm_needed = true;
             }
         }
     }
     if ($afm_needed) {
         require_code('abstract_file_manager');
         force_have_afm_details();
     }
     $cannot_move = new ocp_tempcode();
     foreach ($pages as $page => $type) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 if (!$cannot_move->is_empty()) {
                     $cannot_move->attach(do_lang_tempcode('LIST_SEP'));
                 }
                 $cannot_move->attach(do_lang_tempcode('PAGE_WRITE', escape_html($page)));
                 continue;
             }
         }
     }
     $moved_something = NULL;
     foreach ($pages as $page => $type) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             $moved_something = $page;
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 continue;
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 if ($afm_needed) {
                     afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true));
                 } else {
                     rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page));
                 }
             }
             // If a non-overridden one is there too, need to move that too
             if (strpos($type, '_custom') !== false && file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page)) && !file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page))) {
                 if ($afm_needed) {
                     afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true));
                 } else {
                     rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page));
                 }
             }
             log_it('MOVE_PAGES', $page);
         }
     }
     if (is_null($moved_something)) {
         warn_exit(do_lang_tempcode('NOTHING_SELECTED'));
     }
     persistant_cache_empty();
     require_lang('addons');
     if ($cannot_move->is_empty()) {
         $message = do_lang_tempcode('SUCCESS');
     } else {
         $message = do_lang_tempcode('WOULD_NOT_OVERWRITE_BUT_SUCCESS', $cannot_move);
     }
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:move', do_lang_tempcode('MOVE_PAGES'))));
     decache('main_sitemap');
     if (has_js()) {
         return inform_screen($title, $message);
         // Came from site-tree editor, so want to just close this window when done
     }
     return $this->do_next_manager($title, $moved_something, $new_zone, new ocp_tempcode());
 }
 /**
  * The UI to for the permissions-tree-editor (advanced substitute for the combination of the page permissions screen and various other structure/content-attached screens).
  *
  * @return tempcode		The UI
  */
 function tree_editor()
 {
     $title = get_page_title('PERMISSIONS_TREE');
     if (!has_js()) {
         // Send them to the page permissions screen
         $url = build_url(array('page' => '_SELF', 'type' => 'page'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => 'a376167acf6d0f5ac80ca743a2c728d9', 'URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_PERMISSIONS')));
     }
     require_javascript('javascript_ajax');
     require_javascript('javascript_tree_list');
     require_javascript('javascript_more');
     require_code('form_templates');
     $groups = new ocp_tempcode();
     $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
     $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     $initial_group = NULL;
     foreach ($all_groups as $id => $group_name) {
         if (is_null($initial_group)) {
             $initial_group = $group_name;
         }
         if (!in_array($id, $admin_groups)) {
             $groups->attach(form_input_list_entry(strval($id), $id == $GLOBALS['FORUM_DRIVER']->get_guest_group(), $group_name));
         }
     }
     $css_path = get_custom_file_base() . '/themes/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '/templates_cached/' . user_lang() . '/global.css';
     $color = 'FF00FF';
     if (file_exists($css_path)) {
         $tmp_file = file_get_contents($css_path);
         $matches = array();
         if (preg_match('#\\nth[\\s,][^\\}]*\\sbackground-color:\\s*\\#([\\dA-Fa-f]*);#sU', $tmp_file, $matches) != 0) {
             $color = $matches[1];
         }
     }
     // Standard editing matrix
     // NB: For permissions tree editor, default access is shown as -1 in editor for clarity (because the parent permissions are easily findable which implies the default access would mean something else which would confuse [+ this would be hard to do due to the dynamicness of the interface])
     require_code('permissions2');
     $editor = get_permissions_matrix('', array(), array(), array(), array(), true);
     return do_template('PERMISSIONS_TREE_EDITOR_SCREEN', array('_GUID' => '08bb679a7cfab45c0c29b5393666dd57', 'USERGROUPS' => $all_groups, 'TITLE' => $title, 'INITIAL_GROUP' => $initial_group, 'COLOR' => $color, 'GROUPS' => $groups, 'EDITOR' => $editor));
 }
Beispiel #22
0
/**
 * Evaluate a conventional tempcode variable, handling escaping
 *
 * @param  LANGUAGE_NAME	The language to evaluate this symbol in (some symbols refer to language elements)
 * @param  array				Array of escaping operations
 * @param  integer			The type of symbol this is (TC_SYMBOL, TC_LANGUAGE_REFERENCE)
 * @set    0 2
 * @param  ID_TEXT			The name of the symbol
 * @param  array				Parameters to the symbol. For all but directive it is an array of strings. For directives it is an array of Tempcode objects. Actually there may be template-style parameters in here, as an influence of singular_bind and these may be Tempcode, but we ignore them.
 * @return mixed				The result. Either tempcode, or a string.
 */
function ecv($lang, $escaped, $type, $name, $param)
{
    global $TEMPCODE_SETGET, $CYCLES, $PREPROCESSABLE_SYMBOLS, $DISPLAYED_TITLE;
    //echo '<!--'.$name.'-->'."\n";
    if ($type == TC_SYMBOL) {
        $escaped_codes = $name . ($escaped == array() ? '' : serialize($escaped));
        $cacheable = $param == array() && !isset($GLOBALS['NON_CACHEABLE_SYMBOLS'][$name]);
        if ($cacheable) {
            global $SYMBOL_CACHE;
            if (isset($SYMBOL_CACHE[$escaped_codes])) {
                return $SYMBOL_CACHE[$escaped_codes];
            }
        }
        $value = '';
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($value);
        }
        $temp_array = array();
        if (isset($PREPROCESSABLE_SYMBOLS[$name]) && $name != 'PAGE_LINK') {
            handle_symbol_preprocessing(array($escaped, $type, $name, $param), $temp_array);
        }
        // Late preprocessing. Should not be needed in case of full screen output (as this was properly preprocessed), but is in other cases
        switch ($name) {
            case 'PAGE_LINK':
                if (isset($param[0])) {
                    list($zone, $map, $hash) = page_link_decode(is_object($param[0]) ? $param[0]->evaluate() : $param[0]);
                    $skip = NULL;
                    if (isset($param[4])) {
                        $skip = array_flip(explode('|', $param[4]));
                    }
                    $avoid_remap = isset($param[1]) && $param[1] == '1';
                    $skip_keep = isset($param[2]) && $param[2] == '1';
                    $keep_all = isset($param[3]) && $param[3] == '1';
                    foreach ($map as $key => $val) {
                        if (is_object($val)) {
                            $map[$key] = $val->evaluate();
                        }
                    }
                    $value = _build_url($map, $zone, $skip, $keep_all, $avoid_remap, $skip_keep, $hash);
                } else {
                    $value = get_zone_name() . ':' . get_page_name();
                    foreach ($_GET as $key => $val) {
                        if ($key == 'page') {
                            continue;
                        }
                        if (is_array($val)) {
                            continue;
                        }
                        if (substr($key, 0, 5) == 'keep_' && !skippable_keep($key, $val)) {
                            continue;
                        }
                        $value .= ':' . $key . '=' . $val;
                    }
                }
                break;
            case 'SET':
                if (isset($param[1])) {
                    if (isset($param[1]) && is_object($param[1])) {
                        $TEMPCODE_SETGET[$param[0]] = $param[1];
                    } else {
                        $param_copy = $param;
                        unset($param_copy[0]);
                        $TEMPCODE_SETGET[$param[0]] = implode(',', $param_copy);
                    }
                }
                break;
            case 'GET':
                if (isset($param[0])) {
                    if (isset($TEMPCODE_SETGET[$param[0]])) {
                        if (is_object($TEMPCODE_SETGET[$param[0]])) {
                            $TEMPCODE_SETGET[$param[0]] = $TEMPCODE_SETGET[$param[0]]->evaluate();
                        }
                        $value = $TEMPCODE_SETGET[$param[0]];
                    }
                }
                break;
            case 'EQ':
                if (isset($param[1])) {
                    $first = array_shift($param);
                    $count = 0;
                    foreach ($param as $test) {
                        if ($first == $test) {
                            $count++;
                            break;
                        }
                    }
                    $value = $count != 0 ? '1' : '0';
                }
                break;
            case 'NEQ':
                if (isset($param[1])) {
                    $first = array_shift($param);
                    $count = 0;
                    foreach ($param as $test) {
                        if ($first == $test) {
                            $count++;
                        }
                    }
                    $value = $count == 0 ? '1' : '0';
                }
                break;
            case 'NOT':
                if (isset($param[0])) {
                    $value = $param[0] == '1' || $param[0] == '1' ? '0' : '1';
                }
                break;
            case 'OR':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count > 0 ? '1' : '0';
                break;
            case 'AND':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count == count($param) ? '1' : '0';
                break;
            case 'HAS_ACTUAL_PAGE_ACCESS':
                if (isset($param[0])) {
                    $value = has_actual_page_access($param !== NULL && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], isset($param[1]) ? $param[1] : NULL) ? '1' : '0';
                }
                break;
            case '?':
                if (isset($param[1])) {
                    $value = $param[0] == '1' || $param[0] == '1' ? $param[1] : (isset($param[2]) ? $param[2] : $value);
                }
                break;
            case 'IMG':
                if (isset($param[0]) && isset($GLOBALS['SITE_DB']) && function_exists('find_theme_image') && $GLOBALS['IN_MINIKERNEL_VERSION'] == 0) {
                    $value = find_theme_image($param[0], isset($param[3]) && $param[3] == '1', false, array_key_exists(2, $param) && $param[2] != '' ? $param[2] : NULL, NULL, isset($param[1]) && $param[1] == '1' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']);
                }
                break;
            case '':
                break;
            case 'META_DATA':
                if (isset($param[0])) {
                    global $META_DATA;
                    if (isset($param[1])) {
                        $matches = array();
                        if ($param[0] == 'image' && preg_match('#^' . preg_quote(find_script('attachment'), '#') . '\\?id=(\\d+)#', $param[1], $matches) != 0) {
                            require_code('attachments');
                            if (!has_attachment_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), intval($matches[1]))) {
                                break;
                            }
                        }
                        $META_DATA[$param[0]] = $param[1];
                    } else {
                        $value = isset($META_DATA[$param[0]]) ? strip_comcode($META_DATA[$param[0]]) : '';
                        if ($value === NULL) {
                            $value = '';
                        }
                    }
                }
                break;
            case 'SPECIAL_CLICK_TO_EDIT':
                $_value = do_lang_tempcode('SPECIAL_CLICK_TO_EDIT');
                $value = $_value->evaluate();
                break;
            case 'KEEP':
                // What needs preserving in the URL
                $value = keep_symbol($param);
                break;
            case 'BROWSER':
                if (isset($param[1])) {
                    $q = false;
                    foreach (explode('|', $param[0]) as $browser) {
                        $q = browser_matches($browser);
                        if ($q) {
                            break;
                        }
                    }
                    $value = $q ? $param[1] : (isset($param[2]) ? $param[2] : '');
                    if ($GLOBALS['XSS_DETECT']) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'JAVASCRIPT_INCLUDE':
                if (isset($param[0])) {
                    require_javascript($param[0]);
                    /*// Has to do this inline, as you're not allowed to reference scripts outside head
                    		if (!array_key_exists($param[0],$GLOBALS['JAVASCRIPTS']))
                    		{
                    			$GLOBALS['JAVASCRIPTS'][$param[0]]=1;
                    			$file=javascript_enforce($param[0]);
                    			$_value=do_template('JAVASCRIPT_NEED_INLINE',array('_GUID'=>'d6c907e26c5a8dd8c65f1d36a1a674a9','CODE'=>file_get_contents($file,FILE_TEXT)));
                    			$value=$_value->evaluate();
                    		}*/
                }
                break;
            case 'FACILITATE_AJAX_BLOCK_CALL':
                if (isset($param[0])) {
                    require_javascript('javascript_ajax');
                    require_code('blocks');
                    $_block_constraints = block_params_to_block_signature(block_params_str_to_arr($param[0]));
                    if (array_key_exists(1, $param)) {
                        $_block_constraints = array_merge($_block_constraints, block_params_str_to_arr($param[1]));
                        ksort($_block_constraints);
                    }
                    $block_constraints = block_params_arr_to_str($_block_constraints);
                    // Store permissions
                    $_auth_key = $GLOBALS['SITE_DB']->query_select('temp_block_permissions', array('id', 'p_time'), array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints), '', 1);
                    if (!array_key_exists(0, $_auth_key)) {
                        $auth_key = $GLOBALS['SITE_DB']->query_insert('temp_block_permissions', array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints, 'p_time' => time()), true);
                    } else {
                        $auth_key = $_auth_key[0]['id'];
                        if (time() - $_auth_key[0]['p_time'] > 100) {
                            $GLOBALS['SITE_DB']->query_update('temp_block_permissions', array('p_time' => time()), array('p_session_id' => get_session_id(), 'p_block_constraints' => $block_constraints), '', 1);
                        }
                    }
                    $keep = symbol_tempcode('KEEP');
                    $value = find_script('snippet') . '?snippet=block&auth_key=' . urlencode(strval($auth_key)) . '&block_map=' . urlencode($param[0]) . $keep->evaluate();
                }
                break;
            case 'LANG':
                $value = user_lang();
                break;
            case '_GET':
                if (isset($param[0])) {
                    $value = get_param($param[0], isset($param[1]) ? $param[1] : '', true);
                }
                break;
            case 'QUERY_STRING':
                $value = ocp_srv('QUERY_STRING');
                break;
            case 'USER_AGENT':
                $value = ocp_srv('HTTP_USER_AGENT');
                break;
            case 'STRIP_TAGS':
                if (isset($param[0])) {
                    if (isset($param[1]) && $param[1] == '1') {
                        $value = strip_tags(str_replace('))', ')', str_replace('((', '(', str_replace('<em>', '(', str_replace('</em>', ')', $param[0])))));
                    } else {
                        $value = strip_tags($param[0], array_key_exists(2, $param) ? $param[2] : '');
                    }
                    if (isset($param[1]) && $param[1] == '1') {
                        $value = @html_entity_decode($value, ENT_QUOTES, get_charset());
                    }
                }
                break;
            case 'CONFIG_OPTION':
                if (isset($param[0])) {
                    if (!isset($GLOBALS['OPTIONS'])) {
                        $value = '0';
                    } else {
                        $value = get_option($param[0], true);
                        if ($value === NULL) {
                            $value = '';
                        }
                    }
                }
                break;
            case 'TRUNCATE_LEFT':
                // Truncate the left length of a string. 0: text to truncate, 1: the truncate length, 2: whether to use a tooltip mouse-over if it is truncated, 3: whether it is encoded as HTML (0=no [default, plain-text], 1=yes)
                $value = symbol_truncator($param, 'left');
                break;
            case 'TRUNCATE_RIGHT':
                $value = symbol_truncator($param, 'right');
                break;
            case 'TRUNCATE_SPREAD':
                $value = symbol_truncator($param, 'spread');
                break;
            case 'TRUNCATE_EXPAND':
                $value = symbol_truncator($param, 'expand');
                break;
            case 'THEME':
                if (isset($GLOBALS['FORUM_DRIVER'])) {
                    $value = $GLOBALS['FORUM_DRIVER']->get_theme();
                } else {
                    $value = 'default';
                }
                break;
            case 'REVERSE':
                if (isset($param[0])) {
                    $value = implode(',', array_reverse(explode(',', $param[0])));
                }
                break;
            case 'COMMA_LIST_GET':
                if (isset($param[1])) {
                    require_code('blocks');
                    $values = block_params_str_to_arr($param[0]);
                    $value = isset($values[$param[1]]) ? $values[$param[1]] : '';
                }
                break;
            case 'COMMA_LIST_SET':
                if (isset($param[2])) {
                    require_code('blocks');
                    $values = block_params_str_to_arr($param[0]);
                    $values[$param[1]] = $param[2];
                    $value = block_params_arr_to_str($values);
                }
                break;
            case 'IS_EMPTY':
                if (isset($param[0])) {
                    $value = $param[0] == '' ? '1' : '0';
                }
                break;
            case 'IS_NON_EMPTY':
                if (isset($param[0])) {
                    $value = $param[0] != '' ? '1' : '0';
                }
                break;
            case 'CUSTOM_BASE_URL':
                $value = get_custom_base_url(isset($param[0]) && $param[0] != '' ? $param[0] == '1' : NULL);
                if (isset($param[1]) && $param[1] == '1') {
                    $value = cdn_filter($value);
                }
                break;
            case 'LOAD_PANEL':
                foreach ($param as $i => $p) {
                    if (is_object($p)) {
                        $param[$i] = $p->evaluate();
                    }
                }
                global $LOADED_PANELS;
                if (strpos($param[0], ':') !== false) {
                    $param = array_reverse(explode(':', $param[0], 2));
                }
                if (substr($param[0], 0, 6) == 'panel_') {
                    $param[0] = substr($param[0], 6);
                }
                $sr = serialize($param);
                $value = array_key_exists($sr, $LOADED_PANELS) ? $LOADED_PANELS[$sr] : '';
                break;
            case 'HAS_JS':
            case 'JS_ON':
                if (isset($param[1])) {
                    $value = has_js() ? $param[0] : $param[1];
                } else {
                    $value = has_js() ? '1' : '0';
                }
                break;
            case 'BASE_URL_NOHTTP':
                $value = preg_replace('#^https?://[^/]+#', '', get_base_url());
                if (substr($value, 0, 2) == '//') {
                    $value = substr($value, 1);
                }
                if (!$GLOBALS['DEBUG_MODE']) {
                    break;
                }
                // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            case 'CUSTOM_BASE_URL_NOHTTP':
                $value = preg_replace('#^https?://[^/]+/#', '/', get_custom_base_url());
                if (substr($value, 0, 2) == '//') {
                    $value = substr($value, 1);
                }
                if (!$GLOBALS['DEBUG_MODE']) {
                    break;
                }
                // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            case 'BASE_URL':
                $value = get_base_url(isset($param[0]) ? $param[0] == '1' : NULL);
                break;
            case 'ZONE':
                $value = get_zone_name();
                break;
            case 'PAGE':
                $value = get_page_name();
                break;
            case 'SITE_NAME':
                $value = get_site_name();
                break;
            case 'HEADER_TEXT':
                global $ZONE;
                $value = $ZONE['zone_header_text_trans'];
                break;
            case 'PANEL_WIDTH':
                if (isset($TEMPCODE_SETGET['PANEL_WIDTH']) && $TEMPCODE_SETGET['PANEL_WIDTH'] != '') {
                    $value = $TEMPCODE_SETGET['PANEL_WIDTH'];
                } else {
                    $value = get_option('panel_width', true);
                    if ($value === NULL) {
                        $value = '13.3em';
                    }
                }
                break;
            case 'PANEL_WIDTH_SPACED':
                if (isset($TEMPCODE_SETGET['PANEL_WIDTH_SPACED']) && $TEMPCODE_SETGET['PANEL_WIDTH_SPACED'] != '') {
                    $value = $TEMPCODE_SETGET['PANEL_WIDTH_SPACED'];
                } else {
                    $value = get_option('panel_width_spaced', true);
                    if (is_null($value)) {
                        $value = '14.3em';
                    }
                }
                break;
            case 'TRIM':
                if (isset($param[0])) {
                    $value = preg_replace(array('#^\\s+#', '#^(<br\\s*/?' . '>\\s*)+#', '#^(&nbsp;)+#', '#\\s+$#', '#(<br\\s*/?' . '>\\s*)+$#', '#(&nbsp;)+$#'), array('', '', '', '', '', ''), $param[0]);
                }
                break;
            case 'CPF_VALUE':
                if (isset($param[0])) {
                    if (is_numeric($param[0])) {
                        require_code('ocf_members');
                        $fields = ocf_get_custom_fields_member(isset($param[1]) ? intval($param[1]) : get_member());
                        if (array_key_exists(intval($param[0]), $fields)) {
                            $_value = $fields[intval($param[0])];
                        }
                    } elseif (substr($param[0], 0, 2) == 'm_' && strpos(strtolower($param[0]), 'hash') === false && strpos(strtolower($param[0]), 'salt') === false) {
                        $_value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(isset($param[1]) ? intval($param[1]) : get_member(), $param[0]);
                    } else {
                        $_value = get_ocp_cpf($param[0], isset($param[1]) ? intval($param[1]) : NULL);
                    }
                    if (!is_string($_value)) {
                        $value = is_null($_value) ? '' : strval($_value);
                    } else {
                        $value = $_value;
                    }
                }
                break;
            case 'BANNER':
                if (addon_installed('banners')) {
                    global $SITE_INFO;
                    $is_on_banners = get_option('is_on_banners') == '1' && (!has_specific_permission(get_member(), 'banner_free') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) && get_option('admin_banners') == '1' || !is_null($GLOBALS['CURRENT_SHARE_USER']));
                    if (array_key_exists('throttle_bandwidth_registered', $SITE_INFO)) {
                        $views_till_now = intval(get_value('page_views'));
                        $bandwidth_allowed = $SITE_INFO['throttle_bandwidth_registered'];
                        $total_bandwidth = intval(get_value('download_bandwidth'));
                        if ($bandwidth_allowed * 1024 * 1024 >= $total_bandwidth) {
                            $is_on_banners = false;
                        }
                    }
                    if ($is_on_banners && !is_page_https(get_zone_name(), get_page_name())) {
                        require_code('banners');
                        $b_type = isset($param[0]) ? $param[0] : '';
                        $internal_only = isset($param[1]) ? intval($param[1]) : ($b_type == '' ? 0 : 1);
                        if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) {
                            $_value = banners_script(true, '', '', $b_type, $internal_only, '');
                            $value = $_value->evaluate();
                        } else {
                            $value = 'Banner goes here';
                        }
                    }
                }
                break;
            case 'AVATAR':
                $value = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url(isset($param[0]) ? intval($param[0]) : get_member());
                if (url_is_local($value) && $value != '') {
                    $value = get_custom_base_url() . '/' . $value;
                }
                break;
            case 'IS_GUEST':
                if (isset($param[0])) {
                    $value = is_guest(intval($param[0])) ? '1' : '0';
                } else {
                    $value = is_guest() ? '1' : '0';
                }
                break;
            case 'MEMBER':
                $value = strval(get_member());
                break;
            case 'USER':
                if (!isset($param[0])) {
                    $value = strval(get_member());
                } else {
                    $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($param[0]);
                    $value = is_null($member_id) ? '' : strval($member_id);
                }
                break;
            case 'CSS_INCLUDE':
                if (isset($param[0])) {
                    require_css($param[0]);
                    /*// Has to do this inline, as you're not allowed to reference sheets outside head
                    		if (!array_key_exists($param[0],$GLOBALS['CSSS']))
                    		{
                    			$GLOBALS['CSSS'][$param[0]]=1;
                    			$file=css_enforce($param[0]);
                    			$_value=do_template('CSS_NEED_INLINE',array('_GUID'=>'9de994d2f6d47a622d49347feb7ebe96','CSS'=>str_replace('../../../../',get_base_url().'/',file_get_contents($file,FILE_TEXT))));
                    			$value=$_value->evaluate();
                    		}*/
                }
                break;
            case 'USER_OVERIDE':
                $value = get_param('id', '');
                if (!is_numeric($value) || $value == '') {
                    $value = strval(get_member());
                }
                break;
            case 'IS_HTTPAUTH_LOGIN':
                $value = is_httpauth_login() ? '1' : '0';
                break;
            case 'MEMBER_PROFILE_LINK':
                $value = $GLOBALS['FORUM_DRIVER']->member_profile_url(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member(), false, true);
                if (is_null($value)) {
                    $value = '';
                }
                break;
            case 'USERNAME':
                $value = $GLOBALS['FORUM_DRIVER']->get_username(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member());
                if (is_null($value)) {
                    $value = do_lang('UNKNOWN');
                }
                break;
            case 'CYCLE':
                if (isset($param[0])) {
                    if (!isset($CYCLES[$param[0]])) {
                        $CYCLES[$param[0]] = 0;
                    }
                    if (!isset($param[1])) {
                        $value = strval($CYCLES[$param[0]]);
                    } else {
                        if (count($param) == 2) {
                            $param = array_merge(array($param[0]), explode(',', $param[1]));
                        }
                        ++$CYCLES[$param[0]];
                        if (!array_key_exists($CYCLES[$param[0]], $param)) {
                            $CYCLES[$param[0]] = 1;
                        }
                        $value = $param[$CYCLES[$param[0]]];
                    }
                }
                break;
            case 'THUMBNAIL':
                require_code('images');
                $value = _symbol_thumbnail($param);
                break;
            case 'IMAGE_WIDTH':
                require_code('images');
                list($value, ) = _symbol_image_dims($param);
                break;
            case 'IMAGE_HEIGHT':
                require_code('images');
                list(, $value) = _symbol_image_dims($param);
                break;
            case 'IS_IN_GROUP':
                if (isset($param[0])) {
                    if (in_array($param[count($param) - 1], array('', 'primary', 'secondary'))) {
                        $last_param = $param[count($param) - 1];
                        unset($param[count($param) - 1]);
                    } else {
                        $last_param = '';
                    }
                    $member_id = get_member();
                    $new_param = '';
                    $param_2 = array();
                    foreach ($param as $group) {
                        if (substr($group, 0, 1) == '!' && is_numeric(substr($group, 1))) {
                            $member_id = intval(substr($group, 1));
                        } else {
                            $param_2 = array_merge($param_2, explode(',', $group));
                        }
                    }
                    foreach ($param_2 as $group) {
                        if ($new_param != '') {
                            $new_param .= ',';
                        }
                        $new_param .= $group;
                    }
                    if ($last_param == 'primary') {
                        $member_row = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id);
                        $real_group_list = array($GLOBALS['FORUM_DRIVER']->pname_group($member_row));
                    } elseif ($last_param == 'secondary') {
                        $real_group_list = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id);
                        $member_row = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id);
                        $real_group_list = array_diff($real_group_list, array($GLOBALS['FORUM_DRIVER']->pname_group($member_row)));
                    } else {
                        $real_group_list = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id);
                    }
                    require_code('ocfiltering');
                    $value = count(array_intersect(ocfilter_to_idlist_using_memory($new_param, $GLOBALS['FORUM_DRIVER']->get_usergroup_list()), $real_group_list)) != 0 ? '1' : '0';
                }
                break;
            case 'IS_STAFF':
                if (isset($GLOBALS['FORUM_DRIVER'])) {
                    $value = $GLOBALS['FORUM_DRIVER']->is_staff(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member()) ? '1' : '0';
                } else {
                    $value = '0';
                }
                break;
            case 'IS_SUPER_ADMIN':
                if (isset($GLOBALS['FORUM_DRIVER'])) {
                    $value = $GLOBALS['FORUM_DRIVER']->is_super_admin(!is_null($param) && isset($param[0]) ? intval($param[0]) : get_member()) ? '1' : '0';
                } else {
                    $value = '0';
                }
                break;
            case 'PHOTO':
                if (isset($param[0])) {
                    $value = $GLOBALS['FORUM_DRIVER']->get_member_photo_url(intval($param[0]));
                    if (url_is_local($value) && $value != '') {
                        $value = get_custom_base_url() . '/' . $value;
                    }
                }
                break;
            case 'OCF_RANK_IMAGE':
                if (addon_installed('ocf_forum')) {
                    require_code('ocf_groups');
                    $rank_images = new ocp_tempcode();
                    $member_id = isset($param[0]) ? intval($param[0]) : get_member();
                    $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id, true);
                    foreach ($posters_groups as $group) {
                        $rank_image = ocf_get_group_property($group, 'rank_image');
                        $group_leader = ocf_get_group_property($group, 'group_leader');
                        $group_name = ocf_get_group_name($group);
                        $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only');
                        if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_primary_group'))) {
                            $rank_images->attach(do_template('OCF_RANK_IMAGE', array('USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id), 'GROUP_NAME' => $group_name, 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $member_id)));
                        }
                    }
                    $value = $rank_images->evaluate();
                }
                break;
            case 'TOTAL_POINTS':
                if (addon_installed('points')) {
                    require_code('points');
                    $value = strval(total_points(isset($param[0]) ? intval($param[0]) : get_member()));
                }
                break;
            case 'POINTS_USED':
                if (addon_installed('points')) {
                    require_code('points');
                    $value = strval(points_used(isset($param[0]) ? intval($param[0]) : get_member()));
                }
                break;
            case 'AVAILABLE_POINTS':
                if (addon_installed('points')) {
                    require_code('points');
                    $value = strval(available_points(isset($param[0]) ? intval($param[0]) : get_member()));
                }
                break;
            case 'URL_FOR_GET_FORM':
                if (isset($param[0])) {
                    $url_bits = parse_url($param[0]);
                    if (array_key_exists('scheme', $url_bits)) {
                        $value = $url_bits['scheme'] . '://' . (array_key_exists('host', $url_bits) ? $url_bits['host'] : 'localhost');
                        if (array_key_exists('port', $url_bits) && $url_bits['port'] != 80) {
                            $value .= ':' . strval($url_bits['port']);
                        }
                    }
                    if (array_key_exists('path', $url_bits)) {
                        $value .= $url_bits['path'];
                    }
                }
                break;
            case 'HIDDENS_FOR_GET_FORM':
                $_value = new ocp_tempcode();
                $url_bits = parse_url($param[0]);
                if (array_key_exists('query', $url_bits) && $url_bits['query'] != '') {
                    foreach (explode('&', $url_bits['query']) as $exp) {
                        $parts = explode('=', $exp, 2);
                        if (count($parts) == 2) {
                            if (!in_array($parts[0], $param)) {
                                $_value->attach(form_input_hidden($parts[0], urldecode($parts[1])));
                            }
                        }
                    }
                }
                $value = $_value->evaluate();
                break;
            case 'NOTIFICATIONS_ENABLED':
                $value = '';
                if (array_key_exists(0, $param)) {
                    require_code('notifications');
                    $value = notifications_enabled(array_key_exists(1, $param) ? $param[1] : get_page_name(), $param[0]) ? '1' : '0';
                }
                break;
            case 'DOCUMENT_HELP':
                global $DOCUMENT_HELP, $HELPER_PANEL_TUTORIAL;
                $value = $DOCUMENT_HELP;
                if ($value == '' && $HELPER_PANEL_TUTORIAL != '') {
                    $value = brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/' . $HELPER_PANEL_TUTORIAL;
                }
                break;
            case 'HTTP_STATUS_CODE':
                global $HTTP_STATUS_CODE;
                $value = $HTTP_STATUS_CODE;
                break;
            case 'TEMPCODE':
                if (isset($param[0])) {
                    require_code('tempcode_compiler');
                    $_value = template_to_tempcode($param[0]);
                    $value = $_value->evaluate();
                }
                break;
            case 'COMCODE':
                if (isset($param[0])) {
                    $_value = comcode_to_tempcode($param[0], NULL, true);
                    $value = $_value->evaluate();
                }
                break;
            case 'FLAGRANT':
                $_value = get_flagrant();
                $value = $_value->evaluate();
                break;
            case 'IMG_WIDTH':
            case 'IMG_HEIGHT':
                if (isset($param[0]) && isset($GLOBALS['SITE_DB']) && function_exists('find_theme_image') && $GLOBALS['IN_MINIKERNEL_VERSION'] == 0) {
                    global $THEME_IMG_DIMS_CACHE;
                    if (!isset($THEME_IMG_DIMS_CACHE)) {
                        $THEME_IMG_DIMS_CACHE = function_exists('persistant_cache_get') ? persistant_cache_get('THEME_IMG_DIMS') : array();
                    }
                    if (isset($THEME_IMG_DIMS_CACHE[$param[0]])) {
                        list($width, $height) = $THEME_IMG_DIMS_CACHE[$param[0]];
                        $value = $name == 'IMG_WIDTH' ? $width : $height;
                    } else {
                        if (strpos($param[0], '://') === false) {
                            $img_url = find_theme_image($param[0], false, false, array_key_exists(2, $param) ? $param[2] : NULL, NULL, isset($param[1]) && $param[1] == '1' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']);
                        } else {
                            $img_url = $param[0];
                        }
                        require_code('images');
                        list($width, $height) = _symbol_image_dims(array($img_url));
                        $value = $name == 'IMG_WIDTH' ? $width : $height;
                        $THEME_IMG_DIMS_CACHE[$param[0]] = array($width, $height);
                        if (function_exists('persistant_cache_set')) {
                            persistant_cache_set('THEME_IMG_DIMS', $THEME_IMG_DIMS_CACHE);
                        }
                    }
                }
                break;
            case 'CLEAN_FILE_SIZE':
                if (isset($param[0])) {
                    $bytes = is_numeric($param[0]) ? intval($param[0]) : NULL;
                    require_code('files');
                    $value = clean_file_size($bytes);
                }
                break;
            case 'TIME_PERIOD':
                if (isset($param[0])) {
                    $value = display_time_period(intval($param[0]));
                }
                break;
            case 'MAKE_RELATIVE_DATE':
                if (isset($param[0])) {
                    if (get_option('use_contextual_dates') == '0' && (!array_key_exists(1, $param) || $param[1] != '1')) {
                        $value = get_timezoned_date(intval($param[0]));
                    } else {
                        $value = display_time_period(time() - intval($param[0]));
                    }
                }
                break;
            case 'TIMEZONE':
                $value = make_nice_timezone_name(get_site_timezone());
                break;
            case 'LOAD_PAGE':
                foreach ($param as $i => $p) {
                    if (is_object($p)) {
                        $param[$i] = $p->evaluate();
                    }
                }
                global $LOADED_PAGES;
                if (strpos($param[0], ':') !== false) {
                    $param = array_reverse(explode(':', $param[0], 2));
                }
                $_value = $LOADED_PAGES[serialize($param)];
                $value = $_value->evaluate();
                break;
            case 'RUNNING_SCRIPT':
                if (isset($param[0])) {
                    $value = running_script($param[0]) ? '1' : '0';
                }
                break;
            case 'MATCH_KEY_MATCH':
                $value = '0';
                foreach ($param as $match_key) {
                    if ($match_key == '1' || $match_key == '0' || $match_key == '') {
                        continue;
                    }
                    if (match_key_match($match_key, isset($param[1]) && $match_key == '1')) {
                        $value = '1';
                    }
                }
                break;
            case 'VERSION':
                $value = strval(ocp_version());
                break;
            case 'PREVIEW_VALIDATION':
                $value = get_option('is_on_preview_validation') == '1' ? '1' : '0';
                break;
            case 'BLOCK':
                if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) {
                    foreach ($param as $i => $p) {
                        if (is_object($p)) {
                            $param[$i] = $p->evaluate();
                        }
                    }
                    if (count($param) == 1 && strpos($param[0], ',') !== false) {
                        $param = preg_split('#((?<!\\\\)|(?<=\\\\\\\\)|(?<=^)),#', $param[0]);
                        foreach ($param as $key => $val) {
                            $param[$key] = str_replace('\\,', ',', $val);
                        }
                    }
                    global $LOADED_BLOCKS;
                    if (isset($LOADED_BLOCKS[serialize($param)])) {
                        // Will always be set
                        $value = $LOADED_BLOCKS[serialize($param)]->evaluate();
                    }
                }
                break;
            case 'CURRENCY':
                if (addon_installed('ecommerce')) {
                    if (isset($param[0])) {
                        require_code('currency');
                        $value = currency_convert(floatval(str_replace(',', '', $param[0])), isset($param[1]) && $param[1] != '' ? $param[1] : get_option('currency'), isset($param[2]) && $param[2] != '' ? $param[2] : NULL, isset($param[3]) && $param[3] == '1');
                        if (is_null($value)) {
                            $value = do_lang('INTERNAL_ERROR');
                        }
                    } else {
                        $value = get_option('currency');
                    }
                }
                break;
            case 'CURRENCY_SYMBOL':
                if (addon_installed('ecommerce')) {
                    require_code('ecommerce');
                    $value = ecommerce_get_currency_symbol();
                }
                break;
            case 'GEOLOCATE':
                $value = geolocate_ip(isset($param[0]) ? $param[0] : NULL);
                break;
            case 'NO_SAFE_MODE':
                $value = str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1' ? '0' : '1';
                break;
            case 'FORCE_PREVIEWS':
                if (get_option('forced_preview_option') == '1') {
                    if (get_forum_type() == 'ocf') {
                        if (is_guest() && get_option('default_preview_guests') == '0') {
                            $value = '0';
                        } else {
                            $value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_preview_posts') == 1 ? '1' : '0';
                        }
                    } else {
                        $value = get_option('default_preview_guests') == '0' ? '0' : '1';
                    }
                } else {
                    $value = '0';
                }
                break;
            case 'PREVIEW_URL':
                $value = find_script('preview');
                $value .= '?page=' . get_page_name();
                $value .= '&type=' . get_param('type', '', true);
                break;
            case 'ADDON_INSTALLED':
                if (isset($param[0]) && !running_script('install')) {
                    $value = addon_installed($param[0]) ? '1' : '0';
                }
                break;
            case 'VALUE_OPTION':
                if (isset($param[0])) {
                    $value = function_exists('get_value') ? get_value($param[0]) : '';
                    if (is_null($value)) {
                        $value = function_exists('get_long_value') ? get_long_value($param[0]) : '';
                        if (is_null($value)) {
                            $value = isset($param[1]) ? $param[1] : '';
                            if ($param[0] == 'textmate' && (ocp_srv('HTTP_HOST') == 'localhost' && strpos(ocp_srv('HTTP_USER_AGENT'), 'Macintosh') !== false)) {
                                $value = '1';
                            }
                        }
                    }
                }
                break;
            case 'KEEP_INDEX':
                // What needs preserving in the URL
                $value = 'index.php';
                if (count($_GET) > 0) {
                    foreach ($_GET as $key => $val) {
                        if (is_array($val)) {
                            continue;
                        }
                        if (get_magic_quotes_gpc()) {
                            $val = stripslashes($val);
                        }
                        if (substr($key, 0, 5) == 'keep_' && !skippable_keep($key, $val) && strpos($key, '_expand_') === false) {
                            $value .= ($value == 'index.php' ? '?' : '&') . urlencode($key) . '=' . ocp_url_encode($val);
                        }
                    }
                }
                break;
            case 'HIDE_HELP_PANEL':
                $value = array_key_exists('hide_help_panel', $_COOKIE) && $_COOKIE['hide_help_panel'] == '1' ? '1' : '0';
                break;
            case 'URLISE_LANG':
                if (isset($param[1])) {
                    $_value = urlise_lang($param[0], $param[1], isset($param[2]) ? $param[2] : '', isset($param[3]) ? $param[3] == '1' : false);
                    $value = $_value->evaluate();
                }
                break;
            case 'FIND_SCRIPT_NOHTTP':
                if (isset($param[0]) && function_exists('find_script')) {
                    $value = preg_replace('#^https?://[^/]+#', '', find_script($param[0], false, isset($param[1]) ? intval($param[1]) : 0));
                }
                if (!$GLOBALS['DEBUG_MODE']) {
                    break;
                }
                // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            // Debug mode changes base domain so we need to actually use it in full (fine, we don't have HTTPS in debug mode). Bubble on...
            case 'FIND_SCRIPT':
                if (isset($param[0]) && function_exists('find_script')) {
                    $value = find_script($param[0], false, isset($param[1]) ? intval($param[1]) : 0);
                }
                break;
            case 'MOBILE':
                $value = is_mobile(NULL, array_key_exists(0, $param) ? $param[0] == '1' : false) ? '1' : '0';
                break;
            case 'VALID_FILE_TYPES':
                $value = get_option('valid_types');
                $types = array_flip(explode(',', $value));
                $value = '';
                ksort($types);
                foreach (array_flip($types) as $val) {
                    $value .= $val . ',';
                }
                $value = substr($value, 0, strlen($value) - 1);
                break;
            case 'BROWSER_UA':
                $browser = get_browser_string();
                $value = $browser;
                break;
            case 'OS':
                $os = get_os_string();
                if (is_null($os)) {
                    $os = '';
                }
                $value = $os;
                break;
            case 'ANCHOR':
                if (isset($param[0])) {
                    $_value = do_template('ANCHOR', array('_GUID' => '8795c70c9dd7c6217bb765264ac24092', 'NAME' => $param[0]));
                    $value = $_value->evaluate();
                }
                break;
            case 'CSS_TEMPCODE':
                $_value = css_tempcode();
                $value = $_value->evaluate();
                break;
            case 'JS_TEMPCODE':
                $_value = javascript_tempcode(isset($param[0]) ? $param[0] : NULL);
                $value = $_value->evaluate();
                break;
            case 'PAD_LEFT':
                if (array_key_exists(1, $param)) {
                    $value = str_pad($param[0], intval($param[1]), array_key_exists(2, $param) ? $param[2] : '', STR_PAD_LEFT);
                }
                break;
            case 'PAD_RIGHT':
                if (array_key_exists(1, $param)) {
                    $value = str_pad($param[0], intval($param[1]), array_key_exists(2, $param) ? $param[2] : '', STR_PAD_RIGHT);
                }
                break;
            case 'PAGE_TITLE':
                $value = is_null($DISPLAYED_TITLE) ? '' : $DISPLAYED_TITLE->evaluate();
                break;
            case 'SET_TITLE':
                if (array_key_exists(0, $param)) {
                    get_page_title($param[0], false);
                }
                break;
            case 'EXTRA_HEAD':
                $_value = $GLOBALS['EXTRA_HEAD'];
                if ($_value === NULL) {
                    $_value = new ocp_tempcode();
                }
                $value = $_value->evaluate();
                break;
            case 'EXTRA_FOOT':
                if ($GLOBALS['EXTRA_FOOT'] === NULL) {
                    $GLOBALS['EXTRA_FOOT'] = new ocp_tempcode();
                }
                $_value = $GLOBALS['EXTRA_FOOT'];
                if (array_key_exists(0, $param)) {
                    $GLOBALS['EXTRA_FOOT']->attach($param[0]);
                } else {
                    $value = $_value->evaluate();
                }
                break;
            case 'RAND':
                if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['RAND'])) {
                    $GLOBALS['NO_EVAL_CACHE'] = true;
                    $value = strval(mt_rand(0, 32000));
                } else {
                    $value = '4';
                }
                break;
            case 'SET_RAND':
                if (isset($param[0])) {
                    if (isset($GLOBALS['NON_CACHEABLE_SYMBOLS']['SET_RAND'])) {
                        $GLOBALS['NO_EVAL_CACHE'] = true;
                        $value = $param[mt_rand(0, count($param) - 1)];
                    } else {
                        $value = $param[0];
                    }
                }
                break;
            case 'COPYRIGHT':
                $value = str_replace('$CURRENT_YEAR', date('Y'), get_option('copyright'));
                break;
            case 'KEYWORDS_SPACED':
                $value = str_replace(',', ' ', get_option('keywords'));
                break;
            case 'STAFF_ADDRESS_PURE':
                $value = get_option('staff_address');
                break;
            case 'STAFF_ADDRESS':
                require_code('obfuscate');
                $value = obfuscate_email_address(get_option('staff_address'));
                break;
            case 'DOMAIN':
                $value = get_domain();
                break;
            case 'BRAND_NAME':
                $value = function_exists('get_value') ? get_value('rebrand_name') : NULL;
                if (is_null($value)) {
                    $value = 'ocPortal';
                }
                break;
            case 'BRAND_BASE_URL':
                $value = brand_base_url();
                break;
            case 'SHOW_DOCS':
                $value = get_option('show_docs') === '0' ? '0' : '1';
                break;
            case 'MEMBER_EMAIL':
                $value = $GLOBALS['FORUM_DRIVER']->get_member_email_address(isset($param[0]) ? intval($param[0]) : get_member());
                break;
            case 'OCF_MEMBER_HTML':
                if (get_forum_type() == 'ocf') {
                    require_code('ocf_members');
                    require_code('ocf_members2');
                    $_value = ocf_show_member_box(isset($param[0]) ? intval($param[0]) : get_member());
                    $value = $_value->evaluate();
                }
                break;
            case 'HAS_SPECIFIC_PERMISSION':
                if (isset($param[0])) {
                    $value = has_specific_permission(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0';
                }
                break;
            case 'HAS_ZONE_ACCESS':
                if (isset($param[0])) {
                    $value = has_zone_access(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0';
                }
                break;
            case 'HAS_PAGE_ACCESS':
                if (isset($param[0]) && isset($param[1])) {
                    $value = has_page_access(!is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], $param[1], !is_null($param) && isset($param[3]) ? $param[3] == '1' : false) ? '1' : '0';
                }
                break;
            case 'HAS_CATEGORY_ACCESS':
                if (isset($param[0])) {
                    $value = has_category_access(!is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), $param[0], $param[1]) ? '1' : '0';
                }
                break;
            case 'HAS_ATTACHMENT_ACCESS':
                if (isset($param[0])) {
                    require_code('attachments');
                    $value = has_attachment_access(!is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), $param[0]) ? '1' : '0';
                }
                break;
            case 'HAS_SUBMIT_PERMISSION':
                if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high')) {
                    $value = has_submit_permission(strtolower($param[0]), !is_null($param) && isset($param[1]) ? intval($param[1]) : get_member(), !is_null($param) && isset($param[2]) ? $param[2] : get_ip_address(), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0';
                }
                break;
            case 'HAS_DELETE_PERMISSION':
                if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high') && isset($param[1])) {
                    $value = has_delete_permission(strtolower($param[0]), !is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), intval($param[1]), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0';
                }
                break;
            case 'HAS_EDIT_PERMISSION':
                if (isset($param[0]) && (strtolower($param[0]) == 'low' || strtolower($param[0]) == 'mid' || strtolower($param[0]) == 'high') && isset($param[1])) {
                    $value = has_edit_permission(strtolower($param[0]), !is_null($param) && isset($param[2]) ? intval($param[2]) : get_member(), intval($param[1]), !is_null($param) && isset($param[3]) ? $param[3] : get_page_name()) ? '1' : '0';
                }
                break;
            case 'ENTITY_DECODE':
                if (isset($param[0])) {
                    $value = @html_entity_decode($param[0], ENT_QUOTES, get_charset());
                }
                break;
            case 'RESET_CYCLE':
                if (isset($param[0])) {
                    $CYCLES[$param[0]] = 0;
                }
                break;
            case 'SITE_SCOPE':
                $value = get_option('site_scope');
                break;
            case 'LAST_VISIT_TIME':
                if (get_forum_type() == 'ocf') {
                    $member_info = ocf_read_in_member_profile(get_member(), true);
                    $value = strval($member_info['last_visit_time']);
                }
                break;
            case 'NUM_NEW_TOPICS':
                if (get_forum_type() == 'ocf') {
                    $member_info = ocf_read_in_member_profile(get_member(), true);
                    $_new_topics = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE NOT t_forum_id IS NULL AND t_cache_first_time>' . strval((int) $member_info['last_visit_time']));
                    $new_topics = $_new_topics[0]['mycnt'];
                    $value = strval($new_topics);
                }
                break;
            case 'NUM_NEW_POSTS':
                if (get_forum_type() == 'ocf') {
                    $member_info = ocf_read_in_member_profile(get_member(), true);
                    $_new_posts = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE NOT p_cache_forum_id IS NULL AND p_time>' . strval((int) $member_info['last_visit_time']));
                    $new_posts = $_new_posts[0]['mycnt'];
                    $value = strval($new_posts);
                }
                break;
            case 'HAS_FORUM':
                $value = has_no_forum() ? '0' : '1';
                break;
            case 'OCF':
                $value = get_forum_type() == 'ocf' ? '1' : '0';
                break;
            case 'BOARD_PREFIX':
                $value = get_forum_base_url();
                break;
            case 'DATE_AND_TIME':
                $use_contextual_dates = isset($param[0]) && $param[0] == '1';
                $verbose = isset($param[1]) && $param[1] == '1';
                $server_time = isset($param[2]) && $param[2] == '1';
                $time = isset($param[3]) ? intval($param[3]) : time();
                $value = get_timezoned_date($time, true, $verbose, $server_time, !$use_contextual_dates);
                break;
            case 'DATE':
                $use_contextual_dates = isset($param[0]) && $param[0] == '1';
                $verbose = isset($param[1]) && $param[1] == '1';
                $server_time = isset($param[2]) && $param[2] == '1';
                $time = isset($param[3]) ? intval($param[3]) : time();
                $value = get_timezoned_date($time, false, $verbose, $server_time, !$use_contextual_dates);
                break;
            case 'TIME':
                $time = isset($param[0]) ? intval($param[0]) : time();
                $value = get_timezoned_time($time);
                break;
            case 'SECONDS_PERIOD':
                if (array_key_exists(0, $param)) {
                    $value = display_seconds_period(intval($param[0]));
                }
                break;
            case 'FROM_TIMESTAMP':
                if (isset($param[0])) {
                    $timestamp = isset($param[1]) ? intval($param[1]) : time();
                    if (!array_key_exists(2, $param) || $param[2] == '1') {
                        $timestamp = utctime_to_usertime($timestamp);
                    }
                    $value = locale_filter(my_strftime($param[0], $timestamp));
                    if ($value == $param[0]) {
                        // If no conversion happened then the syntax must have been for 'date' not 'strftime'
                        $value = date($param[0], $timestamp);
                    }
                } else {
                    $timestamp = time();
                    $value = strval($timestamp);
                }
                break;
            case 'TO_TIMESTAMP':
                if (isset($param[0])) {
                    $value = strval(strtotime($param[0]));
                    if (array_key_exists(1, $param) && $param[1] == '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());
                }
                break;
            case 'SESSION_HASHED':
                $value = md5(strval(get_session_id()));
                break;
            case 'SESSION':
                $value = strval(get_session_id());
                break;
            case 'IN_ARRAY':
                if (isset($param[1])) {
                    $array = array_slice($param, 1);
                    $value = in_array($param[0], $array) ? '1' : '0';
                }
                break;
            case 'MULT':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval($param[0]) * floatval($param[1]), 2, true);
                }
                break;
            case 'ROUND':
                if (isset($param[0])) {
                    $amount = isset($param[1]) ? intval($param[1]) : 0;
                    if ($amount > 0) {
                        $value = float_format(floatval($param[0]), $amount);
                    } else {
                        $value = strval(intval(round(floatval($param[0]), $amount)));
                    }
                }
                break;
            case 'DEV_MODE':
                $value = $GLOBALS['DEBUG_MODE'] ? '1' : '0';
                break;
            case 'BROWSER_MATCHES':
                if (isset($param[0])) {
                    $q = false;
                    foreach (explode('|', $param[0]) as $browser) {
                        $q = browser_matches($browser);
                        if ($q) {
                            break;
                        }
                    }
                    $value = $q ? '1' : '0';
                }
                break;
            case 'ISSET':
                if (isset($param[0])) {
                    $value = isset($TEMPCODE_SETGET[$param[0]]) ? '1' : '0';
                }
                break;
            case 'INIT':
                if (isset($param[1])) {
                    if (!isset($TEMPCODE_SETGET[$param[0]])) {
                        $TEMPCODE_SETGET[$param[0]] = $param[1];
                    }
                }
                break;
            case 'INC':
                if (isset($param[0])) {
                    if (!isset($TEMPCODE_SETGET[$param[0]])) {
                        $TEMPCODE_SETGET[$param[0]] = '0';
                    }
                    $TEMPCODE_SETGET[$param[0]] = strval(intval($TEMPCODE_SETGET[$param[0]]) + 1);
                }
                break;
            case 'DEC':
                if (isset($param[0])) {
                    if (!isset($TEMPCODE_SETGET[$param[0]])) {
                        $TEMPCODE_SETGET[$param[0]] = '0';
                    }
                    $TEMPCODE_SETGET[$param[0]] = strval(intval($TEMPCODE_SETGET[$param[0]]) - 1);
                }
                break;
            case 'PREG_MATCH':
                if (isset($param[1])) {
                    $value = preg_match('#' . str_replace('#', '\\#', $param[0]) . '#' . (isset($param[2]) ? str_replace('e', '', $param[2]) : ''), $param[1]) != 0 ? '1' : '0';
                }
                break;
            case 'PREG_REPLACE':
                if (isset($param[2])) {
                    $value = preg_replace('#' . str_replace('#', '\\#', $param[0]) . '#' . (isset($param[3]) ? str_replace('e', '', $param[3]) : ''), $param[1], $param[2]);
                }
                break;
            case 'MAX':
                if (isset($param[0])) {
                    $value = strval(max(intval($param[0]), intval($param[1])));
                }
                break;
            case 'MIN':
                if (isset($param[0])) {
                    $value = strval(min(intval($param[0]), intval($param[1])));
                }
                break;
            case 'MOD':
                if (isset($param[0])) {
                    $value = strval(max(intval($param[0]), -intval($param[0])));
                }
                break;
            case 'REM':
                if (isset($param[1])) {
                    $value = strval(intval($param[0]) % intval($param[1]));
                }
                break;
            case 'DIV_FLOAT':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval($param[0]) / floatval($param[1]), 2, true);
                }
                break;
            case 'DIV':
                if (isset($param[1])) {
                    $value = strval(intval(floor(floatval($param[0]) / floatval($param[1]))));
                }
                break;
            case 'SUBTRACT':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval(str_replace(',', '', $param[0])) - floatval(str_replace(',', '', $param[1])), 2, true);
                }
                break;
            case 'ADD':
                if (isset($param[1])) {
                    $value = float_to_raw_string(floatval(str_replace(',', '', $param[0])) + floatval(str_replace(',', '', $param[1])), 2, true);
                }
                break;
            case 'WCASE':
                if (isset($param[0])) {
                    $value = ucwords($param[0]);
                }
                break;
            case 'LCASE':
                if (isset($param[0])) {
                    $value = ocp_mb_strtolower($param[0]);
                }
                break;
            case 'UCASE':
                if (isset($param[0])) {
                    $value = ocp_mb_strtoupper($param[0]);
                }
                break;
            case '_POST':
                if (isset($param[0])) {
                    $value = post_param($param[0], isset($param[1]) ? $param[1] : '');
                }
                break;
            case 'REPLACE':
                if (isset($param[2])) {
                    $value = str_replace($param[0], $param[1], $param[2]);
                    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'AT':
                if (isset($param[1])) {
                    $value = ocp_mb_substr($param[0], intval($param[1]), 1);
                }
                break;
            case 'STRPOS':
                if (isset($param[1])) {
                    $t_value = strpos($param[0], $param[1]);
                    $value = $t_value === false ? '0' : strval($t_value);
                }
                break;
            case 'IN_STR':
                if (isset($param[1])) {
                    if ($param[1] == '') {
                        $value = '0';
                    } else {
                        $value = '0';
                        foreach ($param as $i => $check) {
                            if (is_integer($i) && $i != 0 && $check != '') {
                                if (strpos($param[0], $check) !== false) {
                                    $value = '1';
                                    break;
                                }
                            }
                        }
                    }
                }
                break;
            case 'SUBSTR_COUNT':
                if (isset($param[1])) {
                    $value = strval(substr_count($param[0], $param[1]));
                }
                break;
            case 'SUBSTR':
                if (isset($param[1])) {
                    $value = ocp_mb_substr($param[0], intval($param[1]), isset($param[2]) ? intval($param[2]) : strlen($param[0]));
                }
                break;
            case 'LENGTH':
                if (isset($param[0])) {
                    $value = strval(ocp_mb_strlen($param[0]));
                }
                break;
            case 'WORDWRAP':
                if (isset($param[1])) {
                    $cut = isset($param[3]) && $param[3] == '1';
                    $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);
                    }
                }
                break;
            case 'ALTERNATOR_TRUNCATED':
                // Alternate values according to whether some given text WOULD have been truncated. 0: text to check against, 1: the truncate length, 2:IF would not be do this, 3: if it would be do this, 4: whether given text is encoded as HTML (0=no [default, plain-text], 1=yes)
                if (isset($param[3])) {
                    $amount = intval($param[1]);
                    $is_html = isset($param[4]) && $param[4] == '1';
                    if (strlen($is_html ? strip_tags($param[0]) : $param[0]) > $amount) {
                        $value = $param[3];
                    } else {
                        $value = $param[2];
                    }
                }
                break;
            case 'ESCAPE':
                if (isset($param[0])) {
                    $d_escaping = array(isset($param[1]) ? constant($param[1]) : ENTITY_ESCAPED);
                    if (is_string($param[0])) {
                        apply_tempcode_escaping($d_escaping, $param[0]);
                    }
                    $value = $param[0];
                }
                break;
            case 'COOKIE_PATH':
                $value = function_exists('get_cookie_path') ? get_cookie_path() : '/';
                break;
            case 'COOKIE_DOMAIN':
                $s_value = function_exists('get_cookie_domain') ? get_cookie_domain() : '';
                $value = is_null($s_value) ? '' : $s_value;
                break;
            case 'IS_A_COOKIE_LOGIN':
                global $IS_A_COOKIE_LOGIN;
                $value = $IS_A_COOKIE_LOGIN && ini_get('suhosin.cookie.max_name_length') !== '64' ? '1' : '0';
                break;
            case 'GROUP_ID':
                if (isset($param[0])) {
                    $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(isset($param[1]) ? intval($param[1]) : get_member());
                    $value = array_key_exists(intval($param[0]), $groups) ? strval($groups[intval($param[0])]) : '';
                }
                break;
            case 'GROUP_NAME':
                if (isset($param[0])) {
                    $groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(isset($param[1]) ? intval($param[1]) : get_member());
                    if (array_key_exists(intval($param[0]), $groups)) {
                        $all_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
                        $value = $all_usergroups[$groups[intval($param[0])]];
                    }
                    if ($GLOBALS['XSS_DETECT'] && ocp_is_escaped($param[0])) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'NEGATE':
                if (isset($param[0])) {
                    $value = strval(-intval($param[0]));
                }
                break;
            case 'XOR':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count == 1 ? '1' : '0';
                break;
            case 'NOR':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count > 0 ? '0' : '1';
                break;
            case 'NAND':
                $count = 0;
                foreach ($param as $test) {
                    if ($test == '1' || $test == '1') {
                        $count++;
                    }
                }
                $value = $count == count($param) ? '0' : '1';
                break;
            case 'LT':
                if (isset($param[1])) {
                    $value = intval($param[0]) < intval($param[1]) ? '1' : '0';
                }
                break;
            case 'GT':
                if (isset($param[1])) {
                    $value = intval($param[0]) > intval($param[1]) ? '1' : '0';
                }
                break;
            case 'COPPA_ON':
                $value = get_option('is_on_coppa') == '1' ? '1' : '0';
                break;
            case 'OBFUSCATE':
                if (isset($param[0])) {
                    require_code('obfuscate');
                    $value = obfuscate_entities($param[0]);
                }
                break;
            case 'FIX_ID':
                if (isset($param[0])) {
                    $value = fix_id($param[0]);
                    if ($GLOBALS['XSS_DETECT']) {
                        ocp_mark_as_escaped($value);
                    }
                }
                break;
            case 'MAILTO':
                require_code('obfuscate');
                $value = mailto_obfuscated();
                break;
            case 'INLINE_STATS':
                $value = get_option('show_inline_stats') == '1' ? '1' : '0';
                break;
            case 'ATTACHMENT_DOWNLOADS':
                if (isset($param[0])) {
                    $db = $GLOBALS['SITE_DB'];
                    if (isset($param[1]) && $param[1] == '1') {
                        $db = $GLOBALS['FORUM_DB'];
                    }
                    $_value = $db->query_value_null_ok('attachments', 'a_num_downloads', array('id' => intval($param[0])));
                    $value = is_null($_value) ? '?' : strval($_value);
                }
                break;
            case 'CSS_DIMENSION_REDUCE':
                if (isset($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';
                    }
                }
                break;
            case 'COMMENT_COUNT':
                if (isset($param[1])) {
                    if (get_option('is_on_comments') == '1') {
                        $count = 0;
                        $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier(get_option('comments_forum_name'), $param[0] . '_' . $param[1]), $count, 0, 0, false);
                        $_value = do_lang_tempcode('_COMMENTS', integer_format(0));
                        if (is_array($_comments)) {
                            $_value = do_lang_tempcode('_COMMENTS', escape_html(integer_format($count)));
                        }
                        $value = $_value->evaluate();
                    } else {
                        $value = do_lang('VIEW');
                    }
                }
                break;
            case 'CAN_SPELLCHECK':
                $value = function_exists('pspell_check') ? '1' : '0';
                break;
            case 'AWARD_ID':
                if (array_key_exists(0, $param)) {
                    $value = $GLOBALS['SITE_DB']->query_value_null_ok('award_archive', 'content_id', array('a_type_id' => intval($param[0])), 'ORDER BY date_and_time DESC');
                    if (is_null($value)) {
                        $value = '';
                    }
                }
                break;
            case 'SELF_PAGE_LINK':
                $value = '';
                if (running_script('index') || running_script('iframe')) {
                    $value = get_zone_name() . ':' . get_page_name();
                    foreach ($_GET as $key => $val) {
                        if ($key == 'page') {
                            continue;
                        }
                        if (is_array($val)) {
                            continue;
                        }
                        if (substr($key, 0, 5) == 'keep_') {
                            continue;
                        }
                        $value .= ':' . $key . '=' . $val;
                    }
                }
                break;
            case 'SET_TUTORIAL_LINK':
                $value = '';
                if (array_key_exists(1, $param) && $param[1] != '' && $param[1][0] != '#') {
                    set_tutorial_link($param[0], $param[1]);
                }
                break;
            case 'DISPLAY_CONCEPT':
                $value = '';
                if (array_key_exists(0, $param)) {
                    $key = $param[0];
                    $page_link = get_tutorial_link('concept___' . preg_replace('#[^\\w_]#', '_', $key));
                    if (is_null($page_link)) {
                        $temp_tpl = make_string_tempcode($key);
                    } else {
                        list($zone, $attributes, $hash) = page_link_decode($page_link);
                        $_url = build_url($attributes, $zone, NULL, false, false, false, $hash);
                        $temp_tpl = do_template('COMCODE_CONCEPT', array('_GUID' => 'ee0cd05f87329923f05145180004d8a8', 'TEXT' => $key, 'URL' => $_url));
                    }
                    $value = $temp_tpl->evaluate();
                }
                break;
            case 'SELF_URL':
                $extra_params = NULL;
                if (isset($param[3])) {
                    $extra_params = array();
                    $i = 3;
                    while (isset($param[$i])) {
                        $bits = explode('=', $param[$i], 2);
                        if ($bits[1] == '<null>') {
                            $bits[1] = NULL;
                        }
                        $extra_params[$bits[0]] = $bits[1];
                        $i++;
                    }
                }
                $value = get_self_url(true, isset($param[0]) && $param[0] == '1', $extra_params, isset($param[1]) && $param[1] == '1', isset($param[2]) && $param[2] == '1');
                break;
            case 'SHIFT_DECODE':
                if (isset($param[0])) {
                    global $SHIFT_VARIABLES;
                    $key = $param[0];
                    $value = isset($SHIFT_VARIABLES[$key]) ? $SHIFT_VARIABLES[$key]->evaluate() : '';
                }
                break;
            case 'NUMBER_FORMAT':
                if (isset($param[0])) {
                    $value = integer_format(intval($param[0]));
                }
                break;
            case 'FLOAT_FORMAT':
                if (isset($param[0])) {
                    $value = float_format(floatval($param[0]));
                }
                break;
            case 'CURRENTLY_INVISIBLE':
                $value = is_invisible() ? '1' : '0';
                break;
            case 'IS_FRIEND':
                if (isset($param[0])) {
                    $test = $GLOBALS['SITE_DB']->query_value_null_ok('chat_buddies', 'member_likes', array('member_likes' => isset($param[1]) ? intval($param[1]) : get_member(), 'member_liked' => intval($param[0])));
                    $value = is_null($test) ? '0' : '1';
                }
                break;
            case 'SSW':
                $value = get_option('ssw') == '1' ? '1' : '0';
                break;
            case 'RATING':
                if (isset($param[1])) {
                    require_code('feedback');
                    $rating = get_rating_simple_array(array_key_exists(3, $param) ? $param[3] : get_self_url(true), array_key_exists(4, $param) ? $param[4] : (is_null($DISPLAYED_TITLE) ? '' : $DISPLAYED_TITLE->evaluate()), $param[0], $param[1], array_key_exists(5, $param) ? $param[5] : 'RATING_FORM', array_key_exists(2, $param) ? $param[2] : NULL);
                    if ($rating !== NULL) {
                        if (!array_key_exists(2, $param) || $param[2] == '0') {
                            $value = isset($rating['ALL_RATING_CRITERIA'][0]['RATING']) ? $rating['ALL_RATING_CRITERIA'][0]['RATING'] : '';
                        } else {
                            $value = do_template('RATING_INLINE_STATIC', $rating);
                        }
                        if (is_object($value)) {
                            $value = $value->evaluate();
                        }
                    }
                }
                break;
            case 'VIEWS':
                if (isset($param[2])) {
                    $id_field = 'id';
                    // Not allowed for security reasons
                    if (preg_match('#^\\w*views\\w*$#', $param[1]) != 0) {
                        $test = $GLOBALS['SITE_DB']->query_value_null_ok($param[0], $param[1], array($id_field => $param[2]));
                        if (!is_null($test)) {
                            $value = integer_format($test);
                        }
                    }
                }
                break;
            default:
                global $EXTRA_SYMBOLS;
                if (is_null($EXTRA_SYMBOLS)) {
                    $EXTRA_SYMBOLS = array();
                    $hooks = find_all_hooks('systems', 'symbols');
                    foreach (array_keys($hooks) as $hook) {
                        $EXTRA_SYMBOLS[$hook] = array();
                    }
                }
                if (array_key_exists($name, $EXTRA_SYMBOLS)) {
                    if (!array_key_exists('ob', $EXTRA_SYMBOLS[$name])) {
                        require_code('hooks/systems/symbols/' . filter_naughty_harsh($name));
                        $EXTRA_SYMBOLS[$name]['ob'] = object_factory('Hook_symbol_' . filter_naughty_harsh($name));
                    }
                    $value = $EXTRA_SYMBOLS[$name]['ob']->run($param);
                    break;
                }
                if (defined($name)) {
                    $value = @strval(constant($name));
                    break;
                }
                $value = '';
                require_code('site');
                attach_message(do_lang_tempcode('MISSING_SYMBOL', escape_html($name)), 'warn');
        }
        if ($escaped != array()) {
            if (is_object($value)) {
                $value = $value->evaluate();
            }
            apply_tempcode_escaping($escaped, $value);
        }
        if ($cacheable) {
            $SYMBOL_CACHE[$escaped_codes] = $value;
        }
        return $value;
    }
    // Is it a directive?
    if ($type == TC_DIRECTIVE) {
        $value = '';
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($value);
        }
        // In our param we should have a map of bubbled template parameters (under 'vars') and our numbered directive parameters
        if ($param === NULL) {
            $param = array();
        }
        // Closure-based Tempcode parser may send in strings, so we need to adapt...
        foreach ($param as $key => $val) {
            if (is_string($val)) {
                $param[$key] = make_string_tempcode($val);
            }
        }
        if (!isset($param['vars'])) {
            $param['vars'] = array();
        }
        switch ($name) {
            case 'SHIFT_ENCODE':
                break;
            case 'PARAM_INFO':
                $_value = do_template('PARAM_INFO', array('MAP' => $param['vars']));
                $value = $_value->evaluate();
                break;
            case 'CSS_INHERIT':
                // e.g. {+START,CSS_INHERIT,global,default,#886aa9}{+END}
                if (isset($param[0])) {
                    require_code('css_and_js');
                    $css_file = $param[0]->evaluate();
                    $theme = isset($param[1]) ? $param[1]->evaluate() : 'default';
                    $seed = isset($param[2]) ? $param[2]->evaluate() : NULL;
                    if ($seed == '') {
                        $seed = NULL;
                    }
                    $dark = isset($param[3]) ? $param[3]->evaluate() == '1' : false;
                    $algorithm = isset($param[4]) ? $param[4]->evaluate() : 'equations';
                    $value = css_inherit($css_file, $theme, $GLOBALS['FORUM_DRIVER']->get_theme(), $seed, $dark, $algorithm);
                }
                break;
            case 'FRACTIONAL_EDITABLE':
                foreach (array_keys($param) as $key) {
                    if (!is_numeric($key)) {
                        unset($param[$key]);
                    }
                }
                if (isset($param[3])) {
                    $edit_text = $param[0]->evaluate();
                    $edit_param_name = $param[1]->evaluate();
                    $edit_pagelink = $param[2]->evaluate();
                    $supports_comcode = (isset($param[4]) ? $param[3]->evaluate() : '0') == '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_zone_access(get_member(), 'adminzone')) {
                        $keep = symbol_tempcode('KEEP');
                        $url = find_script('fractional_edit') . '?edit_param_name=' . urlencode($edit_param_name) . '&supports_comcode=' . ($supports_comcode ? '1' : '0') . '&zone=' . urlencode($zone) . $keep->evaluate();
                        foreach ($attributes as $key => $val) {
                            $url .= '&' . $key . '=' . urlencode($val);
                        }
                        $_value = $param[count($param) - 1];
                        $_value = do_template('FRACTIONAL_EDIT', array('_GUID' => '075ac126c427d28b309004bc67b32b08', 'VALUE' => $_value, 'URL' => $url, 'EDIT_TEXT' => $edit_text, 'EDIT_PARAM_NAME' => $edit_param_name));
                        $value = $_value->evaluate();
                    } else {
                        $value = $param[count($param) - 1]->evaluate();
                    }
                }
                break;
            case 'SET':
                if (isset($param[1])) {
                    $var = $param[0]->evaluate();
                    $set_val = '';
                    $i = 1;
                    while (isset($param[$i])) {
                        if ($i != 1) {
                            $set_val .= ',';
                        }
                        $set_val .= $param[1]->evaluate();
                        $i++;
                    }
                    $TEMPCODE_SETGET[$var] = $set_val;
                }
                break;
            case 'IN_ARRAY':
                if (isset($param[1])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? '1' : '0';
                }
                break;
            case 'NOT_IN_ARRAY':
                if (isset($param[1])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? '0' : '1';
                }
                break;
            case 'IF_IN_ARRAY':
                if (isset($param[2])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? $param[2]->evaluate() : '';
                }
                break;
            case 'IF_NOT_IN_ARRAY':
                if (isset($param[2])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = in_array($param[0]->evaluate(), $array) ? '' : $param[2]->evaluate();
                }
                break;
            case 'IMPLODE':
                if (isset($param[1])) {
                    $key = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    if (isset($param[2]) && $param[2]->evaluate() == '1') {
                        $delim = $param[0]->evaluate();
                        foreach ($array as $key => $val) {
                            if ($value != '') {
                                $value .= $delim;
                            }
                            $value .= (is_integer($key) ? integer_format($key) : $key) . ' = ' . $val;
                        }
                    } else {
                        $value = implode($param[0]->evaluate(), $array);
                    }
                }
                break;
            case 'COUNT':
                if (isset($param[0])) {
                    $key = $param[0]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $value = strval(count($array));
                }
                break;
            case 'BOX':
                unset($param['vars']);
                $title = isset($param[1]) ? $param[0]->evaluate() : '';
                $dimensions = isset($param[2]) ? $param[1]->evaluate() : '100%';
                if ($dimensions == '') {
                    $dimensions = '100%';
                }
                $box_type = isset($param[3]) ? $param[2]->evaluate() : 'classic';
                $options = isset($param[4]) ? $param[3]->evaluate() : '';
                $meta = isset($param[5]) ? $param[4]->evaluate() : '';
                $links = isset($param[6]) ? $param[5]->evaluate() : '';
                $expand = isset($param[7]) ? $param[6]->evaluate() == '1' : false;
                $toplink = isset($param[8]) ? $param[7]->evaluate() : '';
                $tmp = put_in_standard_box(array_pop($param), $title, $dimensions, $box_type, $options, $meta, $links, $expand, $toplink);
                $value = $tmp->evaluate();
                break;
            case 'IF_NON_EMPTY':
                if (isset($param[1])) {
                    if (!$param[0]->is_really_empty()) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_PASSED':
                if (isset($param[1])) {
                    $t = $param[0]->evaluate();
                    if (isset($param['vars'][$t])) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_NON_PASSED':
                if (isset($param[1])) {
                    $t = $param[0]->evaluate();
                    if (!isset($param['vars'][$t])) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_EMPTY':
                if (isset($param[1])) {
                    if ($param[0]->is_really_empty()) {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'IF_ARRAY_EMPTY':
                if (isset($param[0])) {
                    $looking_at = $param[0]->evaluate();
                    if (array_key_exists($looking_at, $param['vars'])) {
                        if (count($param['vars'][$looking_at]) == 0) {
                            $value = $param[1]->evaluate();
                        }
                    }
                }
                break;
            case 'IF_ARRAY_NON_EMPTY':
                if (isset($param[0])) {
                    $looking_at = $param[0]->evaluate();
                    if (array_key_exists($looking_at, $param['vars'])) {
                        if (count($param['vars'][$looking_at]) != 0) {
                            $value = $param[1]->evaluate();
                        }
                    }
                }
                break;
            case 'OF':
                if (isset($param[1])) {
                    $key = $param[0]->evaluate();
                    $x = $param[1]->evaluate();
                    $array = array_key_exists($key, $param['vars']) ? $param['vars'][$key] : array();
                    $x2 = is_numeric($x) ? intval($x) : $x;
                    if (is_integer($x2)) {
                        if ($x2 < 0) {
                            $x2 = count($array) - 1;
                        } elseif ($x2 >= count($array)) {
                            $x2 -= count($array);
                        }
                    }
                    $value = array_key_exists($x2, $array) ? $array[$x2] : '';
                    if (is_object($value)) {
                        $value = $value->evaluate();
                    }
                }
                break;
            case 'INCLUDE':
                if (isset($param[1])) {
                    $tpl_params = $param['vars'];
                    $explode = explode(chr(10), $param[1]->evaluate());
                    foreach ($explode as $val) {
                        $bits = explode('=', $val, 2);
                        if (count($bits) == 2) {
                            $tpl_params[ltrim($bits[0])] = $bits[1];
                        }
                    }
                    $td = isset($param[3]) ? $param[2]->evaluate() : '';
                    if ($td == '') {
                        $td = 'templates';
                    }
                    $ex = isset($param[2]) ? $param[1]->evaluate() : '';
                    if ($ex == '') {
                        $ex = '.tpl';
                    }
                    $_value = do_template($param[0]->evaluate(), $tpl_params, NULL, false, NULL, $ex, $td);
                    $value = $_value->evaluate();
                }
                break;
            case 'WHILE':
                if (isset($param[1])) {
                    $_p = $param[0]->evaluate();
                    if ($_p == '1' || $_p == '1') {
                        $value = '';
                        $value .= $param[1]->evaluate();
                        $value .= ecv($lang, $escaped, $type, $name, $param);
                    }
                }
                break;
            case 'IF':
                if (isset($param[1])) {
                    $_p = $param[0]->evaluate();
                    if ($_p == '1' || $_p == '1') {
                        $value = $param[1]->evaluate();
                    }
                }
                break;
            case 'LOOP':
                if (isset($param[0])) {
                    if (!array_key_exists($param[0]->evaluate(), $param['vars'])) {
                        require_code('site');
                        attach_message(do_lang_tempcode('MISSING_TEMPLATE_PARAMETER', $param[0]->evaluate(), '???'), 'warn');
                        return '';
                    }
                    $array_key = $param[0]->evaluate();
                    if (is_numeric($array_key) || strpos($array_key, ',') !== false) {
                        $array = explode(',', $array_key);
                    } else {
                        $array = array_key_exists($array_key, $param['vars']) ? $param['vars'][$array_key] : array();
                        if (!is_array($array)) {
                            $array = array();
                        }
                    }
                    $value = '';
                    if (array_key_exists(1 + 1, $param)) {
                        $columns = $param[1]->evaluate();
                        $row_starter = array_key_exists(2 + 1, $param) ? $param[2]->evaluate() : '<tr>';
                        $row_terminator = array_key_exists(3 + 1, $param) ? $param[3]->evaluate() : '</tr>';
                        $value .= $row_starter;
                        // Sorting
                        if (array_key_exists(4 + 1, $param)) {
                            $sort_key = $param[4]->evaluate();
                            $rev = array_key_exists(5 + 1, $param) && $param[5]->evaluate() == 'DESC';
                            if ($sort_key != '') {
                                global $M_SORT_KEY;
                                $M_SORT_KEY = $sort_key;
                                uasort($array, 'multi_sort');
                            }
                            if ($rev) {
                                $array = array_reverse($array);
                            }
                        }
                    }
                    $last = count($param) - 2;
                    $col = 0;
                    $first = true;
                    foreach ($array as $go_key => $go) {
                        if (!is_array($go)) {
                            $go = array('_loop_key' => make_string_tempcode(is_integer($go_key) ? strval($go_key) : $go_key), '_loop_var' => make_string_tempcode($go));
                        }
                        // In case it's not a list of maps, but just a list
                        if (isset($param[2]) && $col % $columns == 0 && $col != 0) {
                            $value .= $row_starter;
                        }
                        $ps = $go + $param['vars'] + array('_loop_key' => make_string_tempcode(is_integer($go_key) ? strval($go_key) : $go_key), '_i' => strval($col), '_first' => $first, '_last' => $col == count($array) - 1);
                        $bound = $param[$last]->bind($ps, '');
                        $value .= $bound->evaluate();
                        ++$col;
                        if (isset($param[3]) && $col % $columns == 0) {
                            $value .= $row_terminator;
                        }
                        $first = false;
                    }
                    if (isset($param[2]) && $col % $columns != 0) {
                        $value .= $row_terminator;
                    }
                }
                break;
            default:
                require_code('site');
                attach_message(do_lang_tempcode('UNKNOWN_DIRECTIVE', escape_html($name)), 'warn');
        }
        if ($escaped != array()) {
            apply_tempcode_escaping($escaped, $value);
        }
        return $value;
    }
    // By elimination, it's language
    $a = isset($param[0]) ? is_object($param[0]) ? $param[0]->evaluate() : $param[0] : NULL;
    $b = isset($param[1]) ? is_object($param[1]) ? $param[1]->evaluate() : $param[1] : NULL;
    $c = isset($param[2]) ? array_splice($param, 2) : NULL;
    if ($c !== NULL) {
        foreach ($c as $i => $cc) {
            if (is_object($cc)) {
                $c[$i] = $cc->evaluate();
            }
        }
    }
    static $dle = false;
    if (!$dle) {
        $dle = function_exists('do_lang');
    }
    $ret = $dle ? do_lang($name, $a, $b, $c, $lang, false) : escape_html($name . ':' . (!is_null($a) ? $a : '') . ',' . (!is_null($b) ? $b : ''));
    if ($ret === NULL) {
        if ($type != TC_PARAMETER) {
            require_code('site');
            attach_message(do_lang_tempcode('MISSING_LANG_ENTRY', escape_html($name)), 'warn');
        }
        $value = '';
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($value);
        }
        return $value;
    }
    if ($escaped != array() && $escaped != array(ENTITY_ESCAPED)) {
        apply_tempcode_escaping(array_diff($escaped, array(ENTITY_ESCAPED)), $ret);
    }
    // Escape but without ENTITY_ESCAPED because we don't do that on lang strings
    return $ret;
}