Esempio n. 1
0
 /**
  * Standard modular run function for OcCLE hooks.
  *
  * @param  array	The options with which the command was called
  * @param  array	The parameters with which the command was called
  * @param  array	A reference to the OcCLE filesystem object
  * @return array	Array of stdcommand, stdhtml, stdout, and stderr responses
  */
 function run($options, $parameters, &$occle_fs)
 {
     if (array_key_exists(0, $parameters)) {
         // Load up the relevant block and grab its help output
         $hooks = find_all_hooks('modules', 'admin_occle_commands');
         $hook_return = NULL;
         foreach (array_keys($hooks) as $hook) {
             if ($hook == $parameters[0]) {
                 require_code('hooks/modules/admin_occle_commands/' . filter_naughty_harsh($hook));
                 $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
                 if (is_null($object)) {
                     continue;
                 }
                 $hook_return = $object->run(array('help' => NULL), array(), $occle_fs);
                 break;
             }
         }
         if (!is_null($hook_return)) {
             return array($hook_return[0], $hook_return[1], $hook_return[2], $hook_return[3]);
         } else {
             return array('', '', '', do_lang('NO_HELP'));
         }
     } else {
         // Output a standard "how to use Occle" help page
         return array('window.open(unescape("' . urlencode('http://ocportal.com/docs' . strval(ocp_version()) . '/pg/tut_occle') . '"),"occle_window1","");', '', do_lang('SUCCESS'), '');
     }
 }
Esempio n. 2
0
 /**
  * Do some tests, to make sure we're happy to continue importing.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  * @return ?tempcode		Error/warning UI (NULL: no error/warning)
  */
 function pre_import_tests($db, $table_prefix, $file_base)
 {
     $title = get_page_title('IMPORT');
     $bad = false;
     // Check actually is ocPortal DB (ERROR)
     $test = $db->query_value('zones', 'zone_name');
     if (is_null($test)) {
         return warn_screen($title, do_lang_tempcode('ERROR_NOT_CORRECT_DATABASE'));
     }
     // Check version (WARNING)
     $test = $db->query_value_null_ok('values', 'the_value', array('the_name' => 'version'));
     if (is_null($test) || intval($test) != ocp_version()) {
         attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_VERSION'), 'warn');
         $bad = true;
     }
     // Check actually is ocPortal file path (ERROR)
     if (!file_exists($file_base . '/info.php') || !file_exists($file_base . '/sources_custom')) {
         attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_FILES'), 'warn');
         if (isset($GLOBALS['FORUM_DB']) && $db->connection_write != $GLOBALS['FORUM_DB']->connection_write && !file_exists($file_base . '/info.php')) {
             attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_LINKING_POSSIBLY'), 'warn');
         }
         $bad = true;
     }
     // Check is on same MSN or is OCF (WARNING)
     if (file_exists($file_base . '/info.php')) {
         global $SITE_INFO;
         $backup_site_info = $SITE_INFO;
         $SITE_INFO = NULL;
         @(include $file_base . '/info.php');
         if (is_null($SITE_INFO)) {
             $SITE_INFO = $backup_site_info;
             attach_message(do_lang_tempcode('ERROR_INACESSIBLE_DIR'), 'warn');
             if (isset($GLOBALS['FORUM_DB']) && $db->connection_write != $GLOBALS['FORUM_DB']->connection_write) {
                 attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_LINKING_POSSIBLY'), 'warn');
             }
             $bad = true;
         } else {
             $this_site_info = $SITE_INFO;
             $SITE_INFO = $backup_site_info;
             if (!array_key_exists('db_forums_host', $SITE_INFO)) {
                 $SITE_INFO['db_forums_host'] = 'localhost';
             }
             $same_forum = $this_site_info['db_forums'] == $SITE_INFO['db_forums'] && $this_site_info['db_forums_host'] == $SITE_INFO['db_forums_host'] && $db->table_prefix;
             if ($this_site_info['forum_type'] != 'ocf' && !$same_forum) {
                 attach_message(do_lang_tempcode('ERROR_NOT_CORRECT_LINKING'), 'warn');
                 $bad = true;
             }
         }
     }
     // Show warning
     if ($bad) {
         return do_template('CONFIRM_SCREEN', array('_GUID' => '286928b79830cdff4ac506e4f4f00f3a', 'TITLE' => $title, 'PREVIEW' => do_lang_tempcode('IMPORT_WARNINGS_GIVEN'), 'FIELDS' => build_keep_post_fields(), 'URL' => get_self_url(false, false, array('happy' => 1))));
     }
     return NULL;
 }
Esempio n. 3
0
/**
 * Get template fields to insert into a form page, for manipulation of seo fields.
 *
 * @param  ID_TEXT		The type of resource (e.g. download)
 * @param  ?ID_TEXT		The ID of the resource (NULL: adding)
 * @return tempcode		Form page tempcode fragment
 */
function seo_get_fields($type, $id = NULL)
{
    require_code('form_templates');
    if (is_null($id)) {
        list($keywords, $description) = array('', '');
    } else {
        list($keywords, $description) = seo_meta_get_for($type, $id);
    }
    $fields = new ocp_tempcode();
    if (get_value('disable_seo') !== '1' && (get_value('disable_seo') !== '2' || !is_null($id))) {
        $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $keywords == '' && $description == '', 'TITLE' => do_lang_tempcode('SEO'), 'HELP' => get_option('show_docs') === '0' ? NULL : protect_from_escaping(symbol_tempcode('URLISE_LANG', array(do_lang('TUTORIAL_ON_THIS'), brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_seo', 'tut_seo', '1'))))));
        $fields->attach(form_input_line_multi(do_lang_tempcode('KEYWORDS'), do_lang_tempcode('DESCRIPTION_META_KEYWORDS'), 'meta_keywords[]', array_map('trim', explode(',', preg_replace('#,+#', ',', $keywords))), 0));
        $fields->attach(form_input_line(do_lang_tempcode('META_DESCRIPTION'), do_lang_tempcode('DESCRIPTION_META_DESCRIPTION'), 'meta_description', $description, false));
    }
    return $fields;
}
Esempio n. 4
0
 /**
  * Standard modular run function.
  *
  * @return array		An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option).
  */
 function run()
 {
     $last_cron = get_value('last_cron');
     if (is_null($last_cron) || intval($last_cron) < time() - 60 * 60 * 24) {
         $status = 0;
         $info = NULL;
         $url = brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_configuration';
     } else {
         $status = 1;
         $date = get_timezoned_date(intval($last_cron), true, true, false, true);
         $mails_sent = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) AS cnt FROM ' . get_table_prefix() . 'logged_mail_messages WHERE m_queued=0 AND m_date_and_time>' . strval(time() - 60 * 60 * 24));
         $mails_queued = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) AS cnt FROM ' . get_table_prefix() . 'logged_mail_messages WHERE m_queued=1');
         $info = do_lang_tempcode('LAST_RAN_AT', escape_html($date), escape_html(integer_format($mails_sent)), escape_html(integer_format($mails_queued)));
         $url = '';
     }
     $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1');
     $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('INFO' => $info, 'URL' => '', 'STATUS' => $_status, 'TASK' => urlise_lang(do_lang('NAG_SETUP_CRON'), $url)));
     return array(array($tpl, $status == 0 ? -1 : 0, 1, NULL));
 }
Esempio n. 5
0
 /**
  * Standard modular run function for OcCLE hooks.
  *
  * @param  array	The options with which the command was called
  * @param  array	The parameters with which the command was called
  * @param  array	A reference to the OcCLE filesystem object
  * @return array	Array of stdcommand, stdhtml, stdout, and stderr responses
  */
 function run($options, $parameters, &$occle_fs)
 {
     require_code('version');
     require_code('version2');
     require_lang('version');
     if (array_key_exists('h', $options) || array_key_exists('help', $options)) {
         return array('', do_command_help('version', array('h', 'f', 't', 'v', 'm'), array()), '', '');
     } elseif (array_key_exists('f', $options) || array_key_exists('future', $options)) {
         return array('', get_future_version_information(), '', '');
     } elseif (array_key_exists('t', $options) || array_key_exists('time', $options)) {
         return array('', '', ocp_version_time(), '');
     } elseif ((array_key_exists('v', $options) || array_key_exists('major-version', $options)) && (!array_key_exists('m', $options) && !array_key_exists('minor-version', $options))) {
         return array('', '', ocp_version(), '');
     } elseif ((array_key_exists('m', $options) || array_key_exists('minor-version', $options)) && (!array_key_exists('v', $options) && !array_key_exists('major-version', $options))) {
         return array('', '', ocp_version_minor(), '');
     } elseif ((array_key_exists('g', $options) || array_key_exists('general-version', $options)) && (!array_key_exists('v', $options) && !array_key_exists('major-version', $options))) {
         return array('', '', ocp_version_number(), '');
     } else {
         return array('', '', ocp_version_full(), '');
     }
 }
Esempio n. 6
0
 /**
  * The UI for managing super debranding.
  *
  * @return tempcode		The UI
  */
 function misc()
 {
     $title = get_page_title('SUPER_DEBRAND');
     require_code('form_templates');
     $rebrand_name = get_value('rebrand_name');
     if (is_null($rebrand_name)) {
         $rebrand_name = 'ocPortal';
     }
     $rebrand_base_url = get_value('rebrand_base_url');
     if (is_null($rebrand_base_url)) {
         $rebrand_base_url = 'http://ocportal.com';
     }
     $company_name = get_value('company_name');
     if (is_null($company_name)) {
         $company_name = 'ocProducts';
     }
     $keyboard_map = file_exists(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') ? file_get_contents(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') : file_get_contents(get_file_base() . '/pages/comcode/' . fallback_lang() . '/keymap.txt');
     if (file_exists(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt')) {
         $keyboard_map = file_get_contents(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt');
     }
     if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt')) {
         $adminguide = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt');
     } else {
         $adminguide = do_lang('ADMINGUIDE_DEFAULT_TRAINING');
     }
     if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt')) {
         $start_page = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt');
     } elseif (file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt')) {
         $start_page = file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') ? file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') : file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . fallback_lang() . '/start.txt');
     } else {
         $start_page = do_lang('REBRAND_FRONT_PAGE');
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('REBRAND_NAME'), do_lang_tempcode('DESCRIPTION_REBRAND_NAME'), 'rebrand_name', $rebrand_name, true));
     $fields->attach(form_input_line(do_lang_tempcode('REBRAND_BASE_URL'), do_lang_tempcode('DESCRIPTION_BRAND_BASE_URL', escape_html('docs' . strval(ocp_version()))), 'rebrand_base_url', $rebrand_base_url, true));
     $fields->attach(form_input_line(do_lang_tempcode('COMPANY_NAME'), '', 'company_name', $company_name, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINGUIDE'), do_lang_tempcode('DESCRIPTION_ADMINGUIDE'), 'adminguide', $adminguide, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINSTART_PAGE'), do_lang_tempcode('DESCRIPTION_ADMINSTART_PAGE'), 'start_page', $start_page, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('KEYBOARD_MAP'), '', 'keyboard_map', $keyboard_map, true));
     $fields->attach(form_input_tick(do_lang_tempcode('DELETE_UN_PC'), do_lang_tempcode('DESCRIPTION_DELETE_UN_PC'), 'churchy', false));
     $fields->attach(form_input_tick(do_lang_tempcode('SHOW_DOCS'), do_lang_tempcode('DESCRIPTION_SHOW_DOCS'), 'show_docs', get_option('show_docs') == '1'));
     $fields->attach(form_input_upload(do_lang_tempcode('FAVICON'), do_lang_tempcode('DESCRIPTION_FAVICON'), 'favicon', false, find_theme_image('favicon'), NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('APPLEICON'), do_lang_tempcode('DESCRIPTION_APPLEICON'), 'appleicon', false, find_theme_image('appleicon'), NULL, true, str_replace(' ', '', get_option('valid_images'))));
     if (addon_installed('ocf_avatars')) {
         $fields->attach(form_input_upload(do_lang_tempcode('SYSTEM_AVATAR'), do_lang_tempcode('DESCRIPTION_SYSTEM_AVATAR'), 'system_avatar', false, find_theme_image('ocf_default_avatars/default_set/ocp_fanatic'), NULL, true, str_replace(' ', '', get_option('valid_images'))));
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF');
     $submit_name = do_lang_tempcode('SUPER_DEBRAND');
     return do_template('FORM_SCREEN', array('HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('WARNING_SUPER_DEBRAND_MAJOR_CHANGES'), 'SUBMIT_NAME' => $submit_name));
 }
 /**
  * The do-next manager for before content management.
  *
  * @return tempcode		The UI
  */
 function misc()
 {
     if (!cron_installed()) {
         attach_message(do_lang_tempcode('CRON_NEEDED_TO_WORK', escape_html(brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_configuration')), 'warn');
     }
     require_code('templates_donext');
     return do_next_manager(get_page_title('WELCOME_EMAILS'), comcode_lang_string('DOC_WELCOME_EMAILS'), array(array('add_one', array('_SELF', array('type' => 'ad'), '_SELF'), do_lang('ADD_WELCOME_EMAIL')), array('edit_one', array('_SELF', array('type' => 'ed'), '_SELF'), do_lang('EDIT_WELCOME_EMAIL'))), do_lang('WELCOME_EMAILS'));
 }
Esempio n. 8
0
/**
 * Get the full string version of ocPortal that you are running.
 *
 * @return string			The string saying the full ocPortal version number
 */
function ocp_version_full()
{
    $minor = ocp_version_minor();
    return strval(ocp_version()) . ($minor == '' ? '' : (is_numeric($minor[0]) ? '.' : '-') . $minor);
}
Esempio n. 9
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;
}
Esempio n. 10
0
            if (array_key_exists('author', $details) && $details['author'] != 'admin') {
                $author = $details['author'];
            }
        }
        $file = 'theme-' . preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $theme)) . $version_for_name . '.tar';
        $files2 = array();
        $theme_files = get_directory_contents(get_custom_file_base() . '/themes/' . $theme, 'themes/' . $theme);
        foreach ($theme_files as $file2) {
            if (substr($file2, -4) != '.tcp' && substr($file2, -4) != '.tcd' && substr($file2, -9) != '.editfrom') {
                $files2[] = $file2;
            }
        }
        foreach ($page_files as $file2) {
            $matches = array();
            $regexp = '#^((\\w+)/)?pages/comcode_custom/[^/]*/' . str_replace('#', '\\#', preg_quote($theme)) . '\\_\\_([\\w\\_]+)\\.txt$#';
            if (preg_match($regexp, $file2, $matches) != 0 && $matches[1] != 'docs' . strval(ocp_version())) {
                $files2[] = dirname($file2) . '/' . substr(basename($file2), strlen($theme) + 2);
            }
        }
        $_GET['keep_theme_test'] = '1';
        $_GET['theme'] = $theme;
        create_addon($file, $files2, $name, '', '', $author, 'ocProducts Ltd', '1.0', $description, 'exports/mods');
        echo show_updated_commnets_code($file, $name);
    }
    if ($only !== NULL) {
        echo "All themes have been exported to 'export/mods/'\n";
    }
}
echo "Done\n";
function show_updated_commnets_code($file, $name)
{
Esempio n. 11
0
/**
 * The upgrader.php script handler.
 */
function upgrade_script()
{
    @ini_set('ocproducts.xss_detect', '0');
    require_lang('upgrade');
    require_code('database_action');
    require_code('config2');
    if (function_exists('set_time_limit')) {
        @set_time_limit(180);
    }
    if (array_key_exists('given_password', $_POST)) {
        $given_password = post_param('given_password');
        if (check_master_password($given_password)) {
            $type = get_param('type', 'misc');
            require_code('abstract_file_manager');
            up_do_header();
            if (post_param('ftp_username', '') != '') {
                $_POST['uses_ftp'] = '1';
                _ftp_info(true);
                // To give early error if there's a problem
            }
            // Handle shared site upgrading with no per-site UI
            global $SITE_INFO;
            if (isset($SITE_INFO['custom_file_base_stub'])) {
                require_code('shared_installs');
                $u = current_share_user();
                if (!is_null($u)) {
                    upgrade_sharedinstall_sites();
                    echo '<p>Now regenerate <kbd>template.sql</kbd>, using something like <kbd>mysqldump -uroot -p myocp_site_shareddemo > ~/public_html/template.sql</kbd></p>';
                    up_do_footer();
                    return;
                }
            }
            $show_more_link = true;
            switch ($type) {
                case 'misc':
                    clear_caches_1();
                    $l_choices = do_lang('FU_CHOICES');
                    $oc = get_option('site_closed') == '0' ? do_lang('SITE_OPEN') : do_lang('SITE_CLOSED');
                    $a = float_to_raw_string(ocp_version_number());
                    $b = get_value('version');
                    if (is_null($b)) {
                        $b = '2.5';
                    }
                    $l_up_info = do_lang('FU_UP_INFO' . ($a == $b ? '_1' : '_2'), $a, $b);
                    $l_fu_closedness = do_lang('FU_CLOSENESS', $oc);
                    $l_maintenance = do_lang('FU_MAINTENANCE');
                    $l_upgrading = do_lang('FU_UPGRADING');
                    $l_take_backup = do_lang('FU_TAKE_BACKUP');
                    $l_clear_caches = fu_link('upgrader.php?type=decache', do_lang('FU_CLEAR_CACHES'));
                    $l_check_permissions = fu_link('upgrader.php?type=check_perms', do_lang('FU_CHECK_PERMISSIONS'));
                    $l_fix_permissions = fu_link('upgrader.php?type=fix_perms', do_lang('FU_FIX_PERMISSIONS'));
                    $l_close_site = fu_link('upgrader.php?type=close_site', do_lang('FU_CLOSE_SITE'), get_option('site_closed') == '1');
                    $l_integrity_scan = fu_link('upgrader.php?type=integrity_scan&allow_merging=1', do_lang('FU_INTEGRITY_SCAN'), false, do_lang('FU_WILL_MERGE'));
                    $l_integrity_scan_no_merging = fu_link('upgrader.php?type=integrity_scan', do_lang('FU_INTEGRITY_SCAN_NO_CSS_MERGE'));
                    $l_database_upgrade = fu_link('upgrader.php?type=db_upgrade', do_lang('FU_DATABASE_UPGRADE'));
                    $l_theme_upgrade = fu_link('upgrader.php?type=theme_upgrade', do_lang('FU_THEME_UPGRADE'));
                    $l_open_site = fu_link('upgrader.php?type=open_site', do_lang('FU_OPEN_SITE'), get_option('site_closed') == '0');
                    $l_error_correction = do_lang('FU_ERROR_CORRECTION');
                    $l_not_for_patch = do_lang('FU_NOT_FOR_PATCH');
                    $l_tutorial = fu_link('http://ocportal.com/docs/tut_upgrade.htm', do_lang('FU_TUTORIAL'));
                    $l_release_notes = do_lang('FU_RELEASE_NOTES');
                    $l_refer_release_notes = do_lang('FU_REFER_RELEASE_NOTES');
                    $news_id = post_param_integer('news_id', NULL);
                    $tar_url = '';
                    if (!is_null($news_id)) {
                        require_code('files');
                        $fetch_url = 'http://ocportal.com/uploads/website_specific/ocportal.com/scripts/fetch_release_details.php?news_id=' . strval($news_id) . '&from_version=' . urlencode(strval(ocp_version()) . '.' . ocp_version_minor());
                        $news = http_download_file($fetch_url, NULL, true, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 30.0);
                        $details = unserialize($news);
                        if ($details[0] != '') {
                            $l_refer_release_notes = $details[0] . '<div style="overflow: auto; height: 150px">' . $details[2] . '</div>';
                        }
                        $tar_url = $details[1];
                    }
                    $l_download = fu_link('upgrader.php?type=file_upgrade&tar_url=' . urlencode(base64_encode($tar_url)), do_lang('FU_DOWNLOAD'));
                    $l_important = do_lang('IMPORTANT');
                    $l_bugs = do_lang('FU_BUGS');
                    $l_upgrade_steps = do_lang('FU_UPGRADE_STEPS');
                    $l_action = do_lang('ACTION');
                    $l_step = do_lang('FU_STEP');
                    $l_estimated_time = do_lang('FU_ESTIMATED_TIME');
                    $l_safe_mode = fu_link('index.php?keep_safe_mode=1', do_lang('FU_SAFE_MODE'));
                    $num_addons = $GLOBALS['SITE_DB']->query_value('addons', 'COUNT(*)');
                    $l_addon_management = fu_link('adminzone/index.php?page=admin_addons&keep_safe_mode=1', do_lang('FU_ADDON_MANAGEMENT', integer_format($num_addons)), $num_addons == 0);
                    $l_customisations = do_lang('FU_CUSTOMISATIONS');
                    $closed = comcode_to_tempcode(get_option('closed'), NULL, true);
                    $closed_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'SITE'), get_module_zone('admin_config'), NULL, false, false, false, 'group_CLOSED_SITE');
                    echo "\n<p>{$l_choices}</p>\n\n<div style=\"margin: 0 50px\">\n\t<h2>{$l_maintenance}&hellip;</h2><ul>\n\t\t<li>{$l_clear_caches}</li>\n\t\t<li>{$l_check_permissions}</li>\n\t\t<li>{$l_fix_permissions}</li>\n\t</ul>\n\n\t<h2 style=\"margin-top: 40px\">{$l_upgrading}&hellip;</h2>\n\n\t<h3>{$l_important}</h3>\n\n\t<p>{$l_bugs}</p>\n\n\t<h3>{$l_release_notes}</h3>\n\n\t<p>{$l_refer_release_notes}</p>\n\n\t<h3>{$l_upgrade_steps}</h3>\n\n\t<div class=\"wide_table_wrap\"><table style=\"margin-top: 5px\" class=\"solidborder wide_table spaced_table\">\n\t\t<tr>\n\t\t\t<th>{$l_step}</th>\n\t\t\t<th>{$l_action}</th>\n\t\t\t<th>{$l_estimated_time}</th>\n\t\t</tr>\n\t\t<tr><th>X</th><td>{$l_not_for_patch} {$l_tutorial}</td><td>" . escape_html(display_time_period(60 * 120)) . "</td></tr>\n\t\t<tr><th>1</th><td>{$l_take_backup}</td><td>" . escape_html(display_time_period(60 * 120)) . "</td></tr>\n\t\t<tr><th>2</th><td>{$l_close_site}  {$l_fu_closedness}<br /><q style=\"font-style: italic\">" . $closed->evaluate() . "</q> <span class=\"associated_link_to_small\">[<a href=\"" . escape_html($closed_url->evaluate()) . "\" title=\"(this link will open in a new window)\" target=\"_blank\">" . do_lang('CHANGE') . "</a>]</span></td><td>" . escape_html(display_time_period(60)) . "</td></tr>\n\t\t<tr><th>3</th><td>{$l_download}</td><td>" . escape_html(display_time_period(60 * 5)) . "</td></tr>\n\t\t<tr><th>4</th><td>{$l_not_for_patch} {$l_integrity_scan_no_merging}<!-- " . do_lang('OR') . " {$l_integrity_scan}--></td><td>" . str_replace(' ', '&nbsp;', escape_html(display_time_period(60 * 10))) . "&nbsp;&dagger;</td></tr>\n\t\t<tr><th>5</th><td>{$l_not_for_patch} {$l_database_upgrade}<br />{$l_up_info}</td><td>" . escape_html(display_time_period(60 * 5)) . "</td></tr>\n\t\t<tr><th>6</th><td>{$l_not_for_patch} {$l_theme_upgrade}</td><td>" . escape_html(display_time_period(60 * 5)) . "</td></tr>\n\t\t<tr><th>7</th><td>{$l_clear_caches}</td><td>1 minute</td></tr>\n\t\t<tr><th>8</th><td>{$l_open_site}  {$l_fu_closedness}</td><td>1 minute</td></tr>\n\t</table></div>\n\n\t<p>&dagger; {$l_customisations}</p>\n\n\t<h2 style=\"margin-top: 40px\">{$l_error_correction}&hellip;</h2><ul style=\"margin-top: 5px\">\n\t\t<li>{$l_safe_mode}</li>\n\t\t<li>{$l_addon_management}</li>\n\t</ul>\n</div>\n";
                    $show_more_link = false;
                    break;
                case 'decache':
                    clear_caches_2();
                    echo '<p>' . do_lang('SUCCESS') . '</p>';
                    break;
                case 'check_perms':
                    echo check_perms();
                    break;
                case 'fix_perms':
                    echo fix_perms();
                    break;
                case 'open_site':
                    set_option('site_closed', '0');
                    echo '<p>' . do_lang('SUCCESS') . '</p>';
                    break;
                case 'close_site':
                    set_option('closed', do_lang('FU_CLOSED_FOR_UPGRADES', get_site_name()));
                    set_option('site_closed', '1');
                    echo '<p>' . do_lang('SUCCESS') . '</p>';
                    break;
                case 'file_upgrade':
                    if (get_param('tar_url', '') == '') {
                        echo do_lang('FU_FILE_UPGRADE_INFO');
                    }
                    echo do_lang('FU_FILE_UPGRADE_INFO_MANUAL');
                    echo '<form title="' . do_lang('PROCEED') . '" enctype="multipart/form-data" action="upgrader.php?type=_file_upgrade" method="post">' . post_fields_relay();
                    echo '<label for="url">' . do_lang('URL') . '</label> <input type="text" id="url" name="url" value="' . escape_html(base64_decode(get_param('tar_url', ''))) . '" /> ';
                    if (ocp_srv('HTTP_HOST') == 'ocportal.com' || $GLOBALS['DEBUG_MODE']) {
                        echo '<br /><label for="upload">' . do_lang('UPLOAD') . '</label> <input type="file" id="upload" name="upload" />';
                    }
                    echo '<input type="submit" value="' . do_lang('PROCEED') . '" />';
                    echo '</form>';
                    $show_more_link = false;
                    break;
                case '_file_upgrade':
                    require_code('tar');
                    if (function_exists('set_time_limit')) {
                        @set_time_limit(0);
                    }
                    if (post_param('url', '') == '' && (ocp_srv('HTTP_HOST') == 'ocportal.com' || $GLOBALS['DEBUG_MODE'])) {
                        $temp_path = $_FILES['upload']['tmp_name'];
                    } else {
                        if (post_param('url', '') == '') {
                            warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
                        }
                        $temp_path = ocp_tempnam('ocpfu');
                        $myfile = fopen($temp_path, 'wb');
                        http_download_file(post_param('url'), NULL, true, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $myfile);
                        fclose($myfile);
                    }
                    $upgrade_resource = tar_open($temp_path, 'rb');
                    //tar_extract_to_folder($upgrade_resource,'',true);
                    disable_php_memory_limit();
                    $directory = tar_get_directory($upgrade_resource);
                    // Uses up to around 5MB
                    $data = array('todo' => array());
                    $popup_simple_extract = _ftp_info() === false;
                    if (!$popup_simple_extract) {
                        echo '<p>' . do_lang('EXTRACTING_MESSAGE') . '</p>';
                    }
                    $addon_contents = array();
                    // Find addons
                    foreach ($directory as $upgrade_file2) {
                        // See if we can find an addon registry file in our upgrade TAR
                        if (strpos($upgrade_file2['path'], '/addon_registry/') !== false && substr($upgrade_file2['path'], -4) == '.php') {
                            $file_data = tar_get_file($upgrade_resource, $upgrade_file2['path']);
                            $addon_contents[basename($upgrade_file2['path'], '.php')] = $file_data['data'];
                        }
                    }
                    // Process files
                    foreach ($directory as $offset => $upgrade_file) {
                        // skip over these, from manually installer package (which may be used for an upgrade)
                        if ($upgrade_file['path'] == 'info.php') {
                            continue;
                        }
                        if ($upgrade_file['path'] == 'install.php') {
                            continue;
                        }
                        if ($upgrade_file['path'] == 'install.sql') {
                            continue;
                        }
                        if ($upgrade_file['path'] == 'info.php.template') {
                            continue;
                        }
                        if (!$popup_simple_extract) {
                            // See if we can skip the file, if the on-disk version is identical?
                            if (file_exists(get_file_base() . '/' . $upgrade_file['path']) && filesize(get_file_base() . '/' . $upgrade_file['path']) == $upgrade_file['size']) {
                                $tar_data = tar_get_file($upgrade_resource, $upgrade_file['path']);
                                if (file_get_contents(get_file_base() . '/' . $upgrade_file['path']) == $tar_data['data']) {
                                    echo do_lang('U_SKIPPING_MESSAGE', escape_html($upgrade_file['path'])) . '<br />';
                                    continue;
                                }
                            }
                        }
                        // Addon registry file, for installed addon
                        if (strpos($upgrade_file['path'], '/addon_registry/') !== false && file_exists(get_file_base() . '/' . $upgrade_file['path'])) {
                            if (substr($upgrade_file['path'], -1) != '/') {
                                if ($popup_simple_extract) {
                                    $data['todo'][] = array($upgrade_file['path'], $upgrade_file['mtime'], $offset + 512, $upgrade_file['size'], ($upgrade_file['mode'] & 02) != 0);
                                } else {
                                    $file_data = tar_get_file($upgrade_resource, $upgrade_file['path']);
                                    afm_make_file($upgrade_file['path'], $file_data['data'], ($file_data['mode'] & 02) != 0);
                                    echo do_lang('U_EXTRACTING_MESSAGE', escape_html($upgrade_file['path'])) . '<br />';
                                }
                            }
                        } else {
                            // Some other file
                            $found = NULL;
                            if (substr($upgrade_file['path'], -1) != '/') {
                                foreach ($addon_contents as $addon_name => $addon_data) {
                                    // See if this is the addon for the file
                                    $shortened_path = $upgrade_file['path'];
                                    $shortened_path = preg_replace('#^themes/default/(templates|css)/#', '', $shortened_path);
                                    if (strpos($addon_data, '\'' . addslashes($shortened_path) . '\'') !== false) {
                                        $found = $addon_name;
                                        break;
                                    }
                                }
                            }
                            // Install if either of the following is true:
                            //  - it's some file not in an addon (shouldn't actually happen)
                            //  - it's a new addon (addon that is not installed or uninstalled i.e. does not have an exported mod file)
                            //  - it's a file in an addon we have installed
                            //  - we're upgrading from an ocPortal version that doesn't support addons yet
                            if (is_null($found) || !file_exists(get_file_base() . '/imports/mods/' . $found . '.tar') || file_exists(get_file_base() . '/sources/hooks/systems/addon_registry/' . $found . '.php') || !file_exists(get_file_base() . '/sources/hooks/systems/addon_registry')) {
                                if (substr($upgrade_file['path'], -1) == '/') {
                                    afm_make_directory($upgrade_file['path'], false, true);
                                } else {
                                    if ($popup_simple_extract) {
                                        $data['todo'][] = array($upgrade_file['path'], $upgrade_file['mtime'], $offset + 512, $upgrade_file['size'], ($upgrade_file['mode'] & 02) != 0);
                                    } else {
                                        $file_data = tar_get_file($upgrade_resource, $upgrade_file['path']);
                                        if (!file_exists(get_file_base() . '/' . dirname($upgrade_file['path']))) {
                                            afm_make_directory(dirname($upgrade_file['path']), false, true);
                                        }
                                        afm_make_file($upgrade_file['path'], $file_data['data'], ($file_data['mode'] & 02) != 0);
                                        echo do_lang('U_EXTRACTING_MESSAGE', escape_html($upgrade_file['path'])) . '<br />';
                                    }
                                }
                            }
                            if (substr($upgrade_file['path'], -1) != '/') {
                                // If true: We need to copy it into our archived addon so that addon is kept up-to-date
                                if (!is_null($found) && file_exists(get_file_base() . '/imports/mods/' . $found . '.tar')) {
                                    $old_mod_file = tar_open(get_file_base() . '/imports/mods/' . $found . '.tar', 'rb');
                                    $new_mod_file = tar_open(get_file_base() . '/imports/mods/' . $found . '.new.tar', 'wb');
                                    $directory2 = tar_get_directory($old_mod_file, true);
                                    if (!is_null($directory2)) {
                                        foreach ($directory2 as $d) {
                                            if ($d['path'] == $upgrade_file['path']) {
                                                continue;
                                            }
                                            $file_data = tar_get_file($old_mod_file, $d['path']);
                                            if ($d['path'] == 'mod.inf') {
                                                $file_data['data'] = preg_replace('#^version=.*#m', 'version=(version-synched)', $file_data['data']);
                                            }
                                            tar_add_file($new_mod_file, $d['path'], $file_data['data'], $d['mode'], $d['mtime']);
                                        }
                                        $file_data = tar_get_file($upgrade_resource, $upgrade_file['path']);
                                        tar_add_file($new_mod_file, $upgrade_file['path'], $file_data['data'], $upgrade_file['mode'], $upgrade_file['mtime']);
                                        tar_close($new_mod_file);
                                        tar_close($old_mod_file);
                                        unlink(get_file_base() . '/imports/mods/' . $found . '.tar');
                                        rename(get_file_base() . '/imports/mods/' . $found . '.new.tar', get_file_base() . '/imports/mods/' . $found . '.tar');
                                        echo do_lang('U_PACKING_MESSAGE', escape_html($upgrade_file['path'])) . '<br />';
                                    }
                                }
                            }
                        }
                    }
                    tar_close($upgrade_resource);
                    if ($popup_simple_extract) {
                        copy($temp_path, get_custom_file_base() . '/data_custom/upgrader.tar.tmp');
                        @unlink($temp_path);
                        $temp_path = get_custom_file_base() . '/data_custom/upgrader.tar.tmp';
                        $tmp_data_path = get_custom_file_base() . '/data_custom/upgrader.tmp';
                        $tmp_data_file = fopen($tmp_data_path, 'wb');
                        fwrite($tmp_data_file, serialize($data));
                        fclose($tmp_data_file);
                        global $SITE_INFO;
                        $extract_url = get_base_url() . '/data/upgrader2.php?hashed_password='******'admin_password']) . '&tmp_path=' . urlencode($temp_path) . '&file_offset=0&tmp_data_path=' . urlencode($tmp_data_path) . '&done=' . urlencode(do_lang('DONE'));
                        echo '<p>' . do_lang('FU_EXTRACTING_WINDOW', integer_format(count($data['todo']))) . '</p>';
                        echo '<iframe frameBorder="0" title="" style="width: 100%; height: 400px" src="' . escape_html($extract_url) . '"></iframe>';
                    } else {
                        echo '<p>' . do_lang('SUCCESS') . '</p>';
                        @unlink($temp_path);
                    }
                    unset($_POST['news_id']);
                    break;
                case 'integrity_scan':
                    $allow_merging = either_param_integer('allow_merging', 0);
                    echo run_integrity_check(false, $allow_merging == 1);
                    break;
                case '_integrity_scan':
                    _integrity_scan();
                    echo '<p>' . do_lang('SUCCESS') . '</p>';
                    break;
                case 'db_upgrade':
                    $something_done = false;
                    clear_caches_2();
                    if (version_specific()) {
                        echo do_lang('FU_UPGRADED_CORE_TABLES');
                        $something_done = true;
                    }
                    $done = upgrade_modules();
                    if ($done != '') {
                        echo do_lang('FU_UPGRADE_MODULES', $done);
                        $something_done = true;
                    }
                    if (!$something_done) {
                        echo do_lang('NO_UPGRADE_DONE');
                    }
                    $version_files = ocp_version_number();
                    $_version_database = get_value('ocf_version');
                    $version_database = floatval($_version_database);
                    if (is_null($_version_database)) {
                        $version_database = 2.1;
                    }
                    // Either 2.0 or 2.1, and they are equivalent in terms of what we need to do
                    if ($version_database < $version_files) {
                        echo do_lang('FU_MUST_UPGRADE_OCF', fu_link('upgrader.php?type=ocf', do_lang('FU_UPGRADE_OCF')));
                    }
                    break;
                case 'theme_upgrade':
                    echo upgrade_themes();
                    break;
                case 'ocf':
                    // Only to be launched as a consequent of db_upgrade
                    if (ocf_upgrade()) {
                        echo '<p>' . do_lang('SUCCESS') . '</p>';
                    } else {
                        echo do_lang('FU_NO_OCF_UPGRADE');
                    }
                    break;
            }
            if ($show_more_link) {
                echo '<hr /><div>' . fu_link('upgrader.php?type=misc', do_lang('MORE_OPTIONS')) . '</div>';
            }
        } else {
            up_do_header();
            up_do_login(do_lang('USER_BAD_PASSWORD'));
        }
    } else {
        up_do_header();
        up_do_login();
    }
    up_do_footer();
}
Esempio n. 12
0
/**
 * This is a less-revealing alternative to fatal_exit, that is used for user-errors/common-corruption-scenarios
 *
 * @param  mixed			The error message
 */
function warn_exit($text)
{
    // To break any looping of errors
    global $EXITING;
    if (!is_null($EXITING) || !class_exists('ocp_tempcode')) {
        if (get_domain() == 'localhost' || function_exists('get_member') && has_specific_permission(get_member(), 'see_stack_dump')) {
            die_html_trace($text);
        } else {
            critical_error('RELAY', is_object($text) ? $text->evaluate() : escape_html($text));
        }
    }
    $EXITING = 1;
    $title = get_page_title('ERROR_OCCURRED');
    $echo = new ocp_tempcode();
    $echo->attach(do_template('WARN_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'PROVIDE_BACK' => false)));
    $css_url = 'install.php?type=css';
    $css_url_2 = 'install.php?type=css_2';
    $logo_url = 'install.php?type=logo';
    $version = strval(ocp_version());
    $version .= (is_numeric(ocp_version_minor()) ? '.' : ' ') . ocp_version_minor();
    if (!array_key_exists('step', $_GET)) {
        $_GET['step'] = 1;
    }
    require_code('tempcode_compiler');
    $css_nocache = _do_template('default', '/css/', 'no_cache', 'no_cache', 'EN', '.css');
    $out_final = do_template('INSTALLER_WRAP', array('CSS_NOCACHE' => $css_nocache, 'DEFAULT_FORUM' => '', 'PASSWORD_PROMPT' => '', 'CSS_URL' => $css_url, 'CSS_URL_2' => $css_url_2, 'LOGO_URL' => $logo_url, 'STEP' => integer_format(intval($_GET['step'])), 'CONTENT' => $echo, 'VERSION' => $version));
    $out_final->evaluate_echo();
    exit;
}
Esempio n. 13
0
/**
 * Get the table prefixes used for all ocPortal tables, commonly used when you are installing ocPortal in the same database as your forums. The default table prefix is 'ocp4_'. Note that anything that might write to an arbitrary db, must ask that db for it's table prefix (if it needs it of course... the db abstracts away most needs for it)
 *
 * @return string			The table prefix
 */
function get_table_prefix()
{
    global $SITE_INFO;
    if (!isset($SITE_INFO['table_prefix'])) {
        return 'ocp' . strval(ocp_version()) . '_';
    }
    return $SITE_INFO['table_prefix'];
}
Esempio n. 14
0
 /**
  * The UI to export an addon (2).
  *
  * @return tempcode		The UI
  */
 function _addon_export()
 {
     $hidden = build_keep_post_fields();
     $theme = get_param('theme', NULL, true);
     $title = get_page_title('EXPORT_ADDON');
     // Default meta data
     $name = '';
     $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $organisation = get_site_name();
     $description = '';
     // ... but the theme might already define some of this
     if (!is_null($theme)) {
         $ini_file = ($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini';
         if (file_exists($ini_file)) {
             $details = better_parse_ini_file($ini_file);
             if (array_key_exists('title', $details)) {
                 $name = $details['title'];
             }
             if (array_key_exists('description', $details)) {
                 $description = $details['description'];
             }
             if (array_key_exists('author', $details)) {
                 $author = $details['author'];
             }
         }
     }
     if (get_param('exp', 'custom') == 'lang') {
         $lang = post_param('lang');
         $ini_file = get_custom_file_base() . '/lang_custom/langs.ini';
         if (!file_exists($ini_file)) {
             $ini_file = get_file_base() . '/lang/langs.ini';
         }
         if (file_exists($ini_file)) {
             $details = better_parse_ini_file($ini_file);
             if (array_key_exists($lang, $details)) {
                 $name = $details[$lang];
                 $description = $details[$lang];
             }
         }
     }
     $fields = '';
     /*XHTMLXHTML*/
     require_code('form_templates');
     $field = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true);
     $fields .= $field->evaluate();
     $field = form_input_line(do_lang_tempcode('AUTHOR'), do_lang_tempcode('DESCRIPTION_AUTHOR'), 'author', $author, true);
     $fields .= $field->evaluate();
     $field = form_input_line(do_lang_tempcode('ORGANISATION'), do_lang_tempcode('DESCRIPTION_ORGANISATION'), 'organisation', $organisation, false);
     $fields .= $field->evaluate();
     $field = form_input_line(do_lang_tempcode('_VERSION'), do_lang_tempcode('DESCRIPTION_VERSION'), 'version', '1.0', true);
     $fields .= $field->evaluate();
     $field = form_input_text(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true);
     $fields .= $field->evaluate();
     $field = form_input_line(do_lang_tempcode('DEPENDENCIES'), do_lang_tempcode('DESCRIPTION_DEPENDENCIES'), 'dependencies', '', false);
     $fields .= $field->evaluate();
     $field = form_input_line(do_lang_tempcode('INCOMPATIBILITIES'), do_lang_tempcode('DESCRIPTION_INCOMPATIBILITIES'), 'incompatibilities', '', false);
     $fields .= $field->evaluate();
     if (get_param('exp', 'custom') == 'theme') {
         $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_releasing_themes';
         if (!is_null($theme)) {
             // Option for selecting exactly what files are used
             $field = do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('COUNT_FILES')));
             $fields .= $field->evaluate();
             $files = $this->do_dir('themes/' . $theme);
             $i = 0;
             foreach (array_keys($files) as $file) {
                 $field = form_input_tick(str_replace(array('/', '_'), array('/ ', '_ '), preg_replace('#^themes/' . str_replace('#', '\\#', preg_quote($theme)) . '/#', '', $file)), '', 'file_' . strval($i), true, NULL, $file);
                 $fields .= $field->evaluate();
                 $i++;
             }
             // Option for selecting Comcode pages
             require_lang('themes');
             $field = do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PAGES'), 'HELP' => do_lang_tempcode('THEME_ALSO_INCLUDE_PAGES')));
             $fields .= $field->evaluate();
             $files = $this->do_dir('');
             ksort($files);
             $fields_after = '';
             foreach (array_keys($files) as $file) {
                 if (substr($file, 0, strlen($theme) + 2) == $theme . '__') {
                     $file = substr($file, strlen($theme) + 2);
                 }
                 if (substr($file, -4) == '.txt' && strpos($file, '/comcode_custom/') !== false) {
                     $matches = array();
                     if (preg_match('#^/((\\w+)/)?pages/comcode_custom/[^/]*/(\\w+)\\.txt$#', $file, $matches) != 0 && $matches[1] != 'docs' . strval(ocp_version())) {
                         $auto_ticked = false;
                         if ($matches[1] == '') {
                             $auto_ticked = $matches[3] == 'start' || substr($matches[3], 0, 6) == 'panel_';
                         }
                         $field = form_input_tick($matches[1] . ': ' . $matches[3], '', 'file_' . strval($i), $auto_ticked, NULL, $file);
                         if ($auto_ticked) {
                             $fields .= $field->evaluate();
                         } else {
                             $fields_after .= $field->evaluate();
                         }
                         $i++;
                     }
                 }
             }
             $fields .= $fields_after;
         }
     }
     $submit_name = do_lang_tempcode('EXPORT_ADDON');
     $map = array('page' => '_SELF', 'type' => '__addon_export');
     if (!is_null($theme)) {
         $_redirect = build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone');
         $redirect = $_redirect->evaluate();
         $map['redirect'] = $redirect;
         $map['theme'] = $theme;
     }
     $post_url = build_url($map, '_SELF');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ADDONS')), array('_SELF:_SELF:misc', do_lang_tempcode('EXPORT_ADDON'))));
     breadcrumb_set_self(do_lang_tempcode('CONFIRM'));
     return do_template('FORM_SCREEN', array('_GUID' => 'dd8bea111b0dfc7df7ddc7e2246f0ef9', 'HIDDEN' => $hidden, 'TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'FIELDS' => $fields, 'TEXT' => '', 'URL' => $post_url));
 }
Esempio n. 15
0
 /**
  * The UI to make a normal topic a Private Topic.
  *
  * @return tempcode		The UI
  */
 function make_personal()
 {
     $topic_id = get_param_integer('id');
     $this->check_has_mod_access($topic_id);
     $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1);
     if (!array_key_exists(0, $topic_info)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $a = $topic_info[0]['t_cache_first_username'];
     $b = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $title = get_page_title('MAKE_PERSONAL');
     $text = do_lang_tempcode('MAKE_PERSONAL_DESCRIPTION');
     $submit_name = do_lang_tempcode('MAKE_PERSONAL');
     $post_url = build_url(array('page' => '_SELF', 'type' => '_make_personal'), '_SELF');
     $fields = new ocp_tempcode();
     $hidden = form_input_hidden('id', strval($topic_id));
     $fields->attach(form_input_username(do_lang_tempcode('FROM'), '', 'a', $a, true));
     $fields->attach(form_input_username(do_lang_tempcode('TO'), '', 'b', $b, true));
     return do_template('FORM_SCREEN', array('STAFF_HELP_URL' => brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_correspondance', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
 }
Esempio n. 16
0
/**
 * Build management menu.
 *
 * @return array			Faked database rows
 */
function build_management_menu()
{
    if (is_guest()) {
        return array();
    }
    require_lang('menus');
    require_lang('security');
    $sections = array('start' => array('TOOLTIP' => do_lang('MM_TOOLTIP_START'), 'CURRENT' => false, 'URL' => 'adminzone:', 'CAPTION' => do_lang('ADMIN_HOME'), 'IMG' => 'menu_items/management_navigation/start'), 'usage' => array('TOOLTIP' => do_lang('MM_TOOLTIP_USAGE'), 'CURRENT' => false, 'URL' => 'adminzone:admin:usage', 'CAPTION' => do_lang('USAGE'), 'IMG' => 'menu_items/management_navigation/usage'), 'security' => array('TOOLTIP' => do_lang('MM_TOOLTIP_SECURITY'), 'CURRENT' => false, 'URL' => 'adminzone:admin:security', 'CAPTION' => do_lang('SECURITY'), 'IMG' => 'menu_items/management_navigation/security'), 'setup' => array('TOOLTIP' => do_lang('MM_TOOLTIP_SETUP'), 'CURRENT' => false, 'URL' => 'adminzone:admin:setup', 'CAPTION' => do_lang('SETUP'), 'IMG' => 'menu_items/management_navigation/setup'), 'structure' => array('TOOLTIP' => do_lang('MM_TOOLTIP_STRUCTURE'), 'CURRENT' => false, 'URL' => 'adminzone:admin:structure', 'CAPTION' => do_lang('STRUCTURE'), 'IMG' => 'menu_items/management_navigation/structure'), 'style' => array('TOOLTIP' => do_lang('MM_TOOLTIP_STYLE'), 'CURRENT' => false, 'URL' => 'adminzone:admin:style', 'CAPTION' => do_lang('STYLE'), 'IMG' => 'menu_items/management_navigation/style'), 'tools' => array('TOOLTIP' => do_lang('MM_TOOLTIP_TOOLS'), 'CURRENT' => false, 'URL' => 'adminzone:admin:tools', 'CAPTION' => do_lang('TOOLS'), 'IMG' => 'menu_items/management_navigation/tools'), 'cms' => array('TOOLTIP' => do_lang('MM_TOOLTIP_CMS'), 'CURRENT' => false, 'URL' => 'cms:cms', 'CAPTION' => do_lang('CONTENT'), 'IMG' => 'menu_items/management_navigation/cms'));
    if (get_page_name() == 'admin' && array_key_exists(get_param('type', ''), $sections)) {
        $sections[get_param('type')]['CURRENT'] = true;
    }
    if (get_page_name() == 'cms') {
        $sections['cms']['CURRENT'] = true;
    }
    if (get_zone_name() == 'adminzone' && get_page_name() == 'start') {
        $sections['start']['CURRENT'] = true;
    }
    if ((!has_specific_permission(get_member(), 'avoid_simplified_adminzone_look') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) && num_staff_icons() < MIN_STAFF_ICONS_BEFORE_COLLAPSE) {
        if (num_staff_icons() < MIN_STAFF_ICONS_BEFORE_COLLAPSE) {
            $sections = array();
            $sections[''] = array('TOOLTIP' => '', 'CURRENT' => false, 'URL' => build_url(array('page' => ''), 'site'), 'CAPTION' => do_lang('SITE'), 'IMG' => 'menu_items/management_navigation/start');
            if (has_zone_access(get_member(), 'adminzone')) {
                $sections['start'] = array('TOOLTIP' => '', 'CURRENT' => false, 'URL' => build_url(array('page' => ''), 'adminzone'), 'CAPTION' => do_lang('GUIDE'), 'IMG' => 'menu_items/management_navigation/setup');
            }
            $sections['admin'] = array('TOOLTIP' => '', 'CURRENT' => false, 'URL' => build_url(array('page' => 'cms'), 'cms'), 'CAPTION' => do_lang('OPTIONS'), 'IMG' => 'menu_items/management_navigation/cms');
        }
    }
    if (has_zone_access(get_member(), 'adminzone')) {
        $docs_url = get_option('show_docs') == '0' ? build_url(array('page' => 'website'), 'adminzone') : make_string_tempcode(brand_base_url() . '/docs' . strval(ocp_version()) . '/');
        $sections['docs'] = array('TOOLTIP' => do_lang('MM_TOOLTIP_DOCS'), 'CURRENT' => false, 'URL' => $docs_url, 'CAPTION' => do_lang('DOCS'), 'IMG' => 'menu_items/management_navigation/docs');
    }
    $items = array();
    $hooks = find_all_hooks('systems', 'do_next_menus');
    $collect = array();
    foreach ($hooks as $hook => $sources_dir) {
        $run_function = extract_module_functions(get_file_base() . '/' . $sources_dir . '/hooks/systems/do_next_menus/' . $hook . '.php', array('run'), array(true));
        if (!is_null($run_function[0])) {
            $collect = array_merge($collect, is_array($run_function[0]) ? call_user_func_array($run_function[0][0], $run_function[0][1]) : eval($run_function[0]));
        }
    }
    $i = 1;
    require_all_lang();
    global $M_SORT_KEY;
    $M_SORT_KEY = 'cap';
    foreach ($sections as $type => $section) {
        if (count($sections) > 4 || $type == 'admin') {
            $virtual_type = $type == 'admin' ? '' : $type;
            $items2 = build_stored_menu_hooked($collect, $virtual_type, -$i);
            usort($items2, 'multi_sort');
        } else {
            $items2 = array();
        }
        if (count($items2) != 0 || is_object($section['URL']) || $section['URL'] != '') {
            $items[] = array('id' => -$i, 'i_parent' => NULL, 'cap' => $section['CAPTION'], 'i_caption_long' => $section['TOOLTIP'], 'i_url' => $section['URL'], 'i_theme_img_code' => $section['IMG'], 'i_check_permissions' => 1, 'i_expanded' => 0, 'i_new_window' => 0, 'i_page_only' => '');
            $items = array_merge($items, $items2);
            $i++;
        }
    }
    return $items;
}
Esempio n. 17
0
 /**
  * The UI to edit a page.
  *
  * @return tempcode		The UI
  */
 function _ed()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit';
     require_lang('menus');
     $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_WRITING');
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_comcode_pages';
     $simple_add = get_param_integer('simple_add', 0) == 1;
     $lang = choose_language(get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT'), true);
     if (is_object($lang)) {
         return $lang;
     }
     if (addon_installed('page_management')) {
         // Add to menu
         if (get_param('menu', STRING_MAGIC_NULL) != STRING_MAGIC_NULL && has_actual_page_access(get_member(), 'admin_sitetree')) {
             require_code('menus2');
             add_menu_item_simple(get_param('menu'), NULL, get_param('title'), get_param('page_link'), 0, 0, false);
         }
     }
     // Work out what we're editing, and where it's coming from (support for two pagelink specifying parameters for destination, with addition of restore_from to override source if different from destination)
     $page_link = filter_naughty(get_param('page_link', ''));
     if ($page_link == '') {
         $page_link = get_param('page_link_2');
     }
     if (strpos($page_link, ':') === false) {
         $page_link = ':' . $page_link;
     }
     $page_link_parts = explode(':', $page_link);
     if (count($page_link_parts) != 2) {
         warn_exit(do_lang_tempcode('ZONE_COLON_FILE'));
     }
     $zone = $page_link_parts[0];
     if ($zone != '' && !file_exists(get_file_base() . '/' . $zone . '/pages')) {
         warn_exit(do_lang_tempcode('NO_SUCH_ZONE'));
     }
     $file = $page_link_parts[1];
     require_code('type_validation');
     if (!is_alphanumeric($file, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
     check_edit_permission('high', $resource_owner);
     if (is_null($resource_owner)) {
         check_submit_permission('high');
     }
     $restore_from = $this->find_comcode_page($lang, $file, $zone);
     // Check no redirects in our way
     if (addon_installed('redirects_editor')) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('redirects', 'r_to_zone', array('r_from_page' => $file, 'r_from_zone' => $zone));
         if (!is_null($test)) {
             $redirect_url = build_url(array('page' => 'admin_redirects'), get_module_zone('admin_redirects'));
             attach_message(do_lang_tempcode('BLOCKING_REDIRECT_IN_PLACE', escape_html($redirect_url->evaluate())), 'notice');
         }
     }
     $title = get_page_title($simple_add || $file == '' ? 'COMCODE_PAGE_ADD' : '_COMCODE_PAGE_EDIT', true, array(escape_html($zone), escape_html($file)));
     if (!$simple_add && $file != '') {
         breadcrumb_set_self(do_lang_tempcode('COMCODE_PAGE_EDIT'));
     }
     if (!has_actual_page_access(get_member(), $file, $zone)) {
         access_denied('PAGE_ACCESS');
     }
     // Default file contents
     $contents = post_param('new', '');
     $parsed = NULL;
     if ($contents == '') {
         $file_base = strpos($restore_from, 'comcode_custom/') ? get_custom_file_base() : get_file_base();
         if (!is_file($file_base . '/' . $restore_from)) {
             $file_base = get_file_base();
         }
         if (is_file($file_base . '/' . $restore_from)) {
             $contents = file_get_contents($file_base . '/' . $restore_from, FILE_TEXT);
             if (is_null(get_param('restore_from', NULL))) {
                 $string_index = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'string_index', array('the_zone' => $zone, 'the_page' => $file));
                 if (!is_null($string_index)) {
                     $parsed = get_translated_tempcode($string_index, NULL, $lang);
                 }
             }
             $new = false;
         } elseif (get_param('title', '') != '') {
             $page_pretty_title = get_param('title', '');
             $contents = '[title]' . $page_pretty_title . "[/title]\n\n" . do_lang('PAGE_DEFAULT_TEXT');
             $new = true;
         } else {
             $contents = '[title]' . do_lang('PAGE_DEFAULT_TITLE') . "[/title]\n\n";
             $new = true;
         }
         if ($new && get_option('is_on_comcode_page_children') == '1') {
             $contents .= chr(10) . chr(10) . '[block]main_comcode_page_children[/block]';
         }
     } else {
         $new = false;
     }
     $map = array('page' => '_SELF', 'type' => '__ed', 'wide' => 1);
     if ($simple_add) {
         $map['simple_add'] = '1';
     }
     $post_url = build_url($map, '_SELF');
     // Revision history
     $filesarray = $this->get_comcode_revisions($zone, 'comcode_custom/' . $lang, $file . '.txt');
     rsort($filesarray);
     $i = 0;
     $revision_history = new ocp_tempcode();
     $max = intval(get_option('number_revisions_show'));
     $last_path = $file_base . '/' . $restore_from;
     if (is_file($last_path)) {
         foreach ($filesarray as $iterator => $stuff) {
             list($filepath, $time) = $stuff;
             // Find who did the revision
             $editor = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'the_user', array('date_and_time' => $time, 'the_type' => 'COMCODE_PAGE_EDIT', 'param_a' => $file));
             if (has_specific_permission(get_member(), 'view_revision_history') || $editor == get_member()) {
                 if (is_null($editor)) {
                     $editor = do_lang('UNKNOWN');
                 } else {
                     $editor = $GLOBALS['FORUM_DRIVER']->get_username($editor);
                     if (is_null($editor)) {
                         $editor = do_lang('UNKNOWN');
                     }
                 }
                 $old_file = (strpos($filepath, '_custom/') ? get_custom_file_base() : get_file_base()) . '/' . $filepath;
                 $size = filesize($old_file);
                 $date = get_timezoned_date($time);
                 $url = get_custom_base_url() . '/' . $zone . '/' . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time);
                 $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => zone_black_magic_filterer($zone . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time), true)), '_SELF');
                 require_code('diff');
                 if (function_exists('diff_simple')) {
                     $rendered_diff = diff_simple($old_file, $last_path);
                     $last_path = $old_file;
                     if ($rendered_diff == '' && $iterator == 0) {
                         continue;
                     }
                     // the version records are often saved on create not replace
                     $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => '57e2c81fd621d1c8d6e283a5a4991001', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size))));
                     $i++;
                 }
                 if ($i == $max) {
                     break;
                 }
             }
         }
         if (strpos($restore_from, '/comcode_custom/') !== false && zone_black_magic_filterer($zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt', true) != $restore_from && is_file(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'))) {
             $url = get_base_url() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt';
             $size = filesize(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'));
             $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => $zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $lang . '/' . $file . '.txt'), '_SELF');
             require_code('diff');
             if (function_exists('diff_simple')) {
                 $rendered_diff = diff_simple(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'), $last_path);
                 $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'ed0b29f26cf93d4d6e0348a7e75d259d', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size))));
                 $i++;
             }
         }
     }
     if (!$revision_history->is_empty() && get_param('restore_from', '') == '') {
         $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '2349ee62cae037ec3cf1766403c92b39', 'CONTENT' => $revision_history));
     } elseif (!$revision_history->is_empty()) {
         $revision_history = do_template('REVISION_RESTORE');
     }
     $meta_keywords = post_param('meta_keywords', '');
     $meta_description = post_param('meta_description', '');
     if ($meta_keywords == '' && $meta_description == '') {
         list($meta_keywords, $meta_description) = seo_meta_get_for('comcode_page', $zone . ':' . $file);
     }
     $hidden_fields = new ocp_tempcode();
     if (addon_installed('page_management') && has_actual_page_access(get_member(), 'adminzone')) {
         $delete_url = build_url(array('page' => 'admin_sitetree', 'type' => '_delete', 'page__' . $file => 1, 'zone' => $zone), get_module_zone('admin_sitetree'));
     } else {
         $delete_url = new ocp_tempcode();
     }
     $fields = new ocp_tempcode();
     $fields2 = new ocp_tempcode();
     require_code('form_templates');
     if (addon_installed('page_management')) {
         if (has_actual_page_access(get_member(), 'admin_sitetree')) {
             if ($simple_add) {
                 $hidden_fields->attach(form_input_hidden('title', $file));
             } else {
                 $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'title', $file, true));
             }
         }
     }
     $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_zone' => $zone, 'the_page' => $file));
     if (array_key_exists(0, $rows)) {
         $validated = $rows[0]['p_validated'] == 1;
         $parent_page = $rows[0]['p_parent_page'];
         $show_as_edit = $rows[0]['p_show_as_edit'] == 1;
         $owner = $rows[0]['p_submitter'];
     } else {
         global $NON_CANONICAL_PARAMS;
         $NON_CANONICAL_PARAMS[] = 'parent_page';
         $validated = true;
         $parent_page = get_param('parent_page', '');
         $show_as_edit = false;
         $owner = get_member();
     }
     $_pages = find_all_pages($zone, 'comcode/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     $_pages += find_all_pages($zone, 'comcode_custom/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     $_pages += find_all_pages($zone, 'comcode/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     $_pages += find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     ksort($_pages);
     $pages = form_input_list_entry('', false, do_lang_tempcode('NA_EM'));
     foreach (array_keys($_pages) as $page) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if ($page != $file) {
             $pages->attach(form_input_list_entry($page, $parent_page == $page));
         }
     }
     if (!$simple_add) {
         if (!$validated) {
             $validated = get_param_integer('validated', 0) == 1;
         }
         if (has_specific_permission(get_member(), 'bypass_validation_highrange_content')) {
             if (addon_installed('unvalidated')) {
                 $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated));
             }
         }
         if (!$new) {
             if ($delete_url->is_empty()) {
                 $fields2->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
             }
         }
     } else {
         $hidden_fields->attach(form_input_hidden('validated', '1'));
     }
     if (get_option('is_on_comcode_page_children') == '1') {
         $fields2->attach(form_input_list(do_lang_tempcode('PARENT_PAGE'), do_lang_tempcode('DESCRIPTION_PARENT_PAGE'), 'parent_page', $pages, NULL, false, false));
     }
     if (!$simple_add) {
         $fields2->attach(form_input_tick(do_lang_tempcode('SHOW_AS_EDITED'), do_lang_tempcode('DESCRIPTION_SHOW_AS_EDITED'), 'show_as_edit', $show_as_edit));
         if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
             $fields2->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_OWNER'), 'owner', $GLOBALS['FORUM_DRIVER']->get_username($owner), true));
         }
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SEO'), 'SECTION_HIDDEN' => true, 'HELP' => get_option('show_docs') == '0' ? NULL : protect_from_escaping(symbol_tempcode('URLISE_LANG', array(do_lang('TUTORIAL_ON_THIS'), brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_seo', 'tut_seo', '1'))))));
         $fields2->attach(form_input_line_multi(do_lang_tempcode('KEYWORDS'), do_lang_tempcode('DESCRIPTION_META_KEYWORDS'), 'meta_keywords[]', array_map('trim', explode(',', preg_replace('#,+#', ',', $meta_keywords))), 0));
         $fields2->attach(form_input_line(do_lang_tempcode('META_DESCRIPTION'), do_lang_tempcode('DESCRIPTION_META_DESCRIPTION'), 'meta_description', $meta_description, false));
     }
     // Awards?
     if (addon_installed('awards')) {
         require_code('awards');
         $fields2->attach(get_award_fields('comcode_page', $zone . ':' . $file));
     }
     require_code('permissions2');
     $fields2->attach(get_page_permissions_for_environment($zone, $file));
     $hidden_fields->attach(form_input_hidden('file', $file));
     $hidden_fields->attach(form_input_hidden('lang', $lang));
     $hidden_fields->attach(form_input_hidden('zone', $zone));
     $hidden_fields->attach(form_input_hidden('redirect', get_param('redirect', '')));
     $posting_form = get_posting_form(do_lang($simple_add ? 'COMCODE_PAGE_ADD' : 'SAVE'), $contents, $post_url, $hidden_fields, $fields, do_lang_tempcode('COMCODE_PAGE'), '', $fields2, $parsed, NULL, NULL, false);
     $export_url = build_url(array('page' => '_SELF', 'type' => 'export', 'page_link' => $page_link, 'export' => $restore_from, 'lang' => $lang), '_SELF');
     $text = new ocp_tempcode();
     if (addon_installed('points')) {
         $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login'));
         $_login_url = escape_html($login_url->evaluate());
         if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) {
             $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url)));
         }
     }
     list($warning_details, $ping_url) = handle_conflict_resolution($page_link);
     if (!$simple_add) {
         breadcrumb_set_parents(array(array('_SELF:_SELF:misc:lang=' . $lang, do_lang_tempcode('CHOOSE'))));
     }
     return do_template('COMCODE_EDIT_SCREEN', array('_GUID' => 'ec1d773684757f5bf6f39cf931555bf2', 'NEW' => $new, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $text, 'TITLE' => $title, 'DELETE_URL' => $delete_url, 'ZONE' => $zone, 'FILE' => $file, 'EXPORT_URL' => $export_url, 'POSTING_FORM' => $posting_form, 'REVISION_HISTORY' => $revision_history));
 }
Esempio n. 18
0
 /**
  * The UI for managing temporary usergroup memberships.
  *
  * @return tempcode		The UI
  */
 function group_member_timeouts()
 {
     $title = get_page_title('GROUP_MEMBER_TIMEOUTS');
     if (!cron_installed()) {
         attach_message(do_lang_tempcode('CRON_NEEDED_TO_WORK', escape_html(brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_configuration')), 'warn');
     }
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/usergroups_temp';
     breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS'))));
     require_code('form_templates');
     require_code('templates_results_table');
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 100);
     $max_rows = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_value('f_group_member_timeouts', 'COUNT(*)');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('_USERGROUP'), do_lang_tempcode('TIME')));
     $timeouts = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_select('f_group_member_timeouts', array('member_id', 'group_id', 'timeout'), NULL, '', $max, $start);
     $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
     $tfields = new ocp_tempcode();
     foreach ($timeouts as $timeout) {
         $tfields->attach(results_entry(array($GLOBALS['FORUM_DRIVER']->get_username($timeout['member_id']), isset($usergroups[$timeout['group_id']]) ? $usergroups[$timeout['group_id']] : do_lang('UNKNOWN'), display_time_period($timeout['timeout'] - time())), true));
     }
     $results_table = results_table(do_lang('GROUP_MEMBER_TIMEOUTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $tfields);
     $fields = new ocp_tempcode();
     $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), '', 'username', '', true));
     $_usergroups = new ocp_tempcode();
     foreach ($usergroups as $uid => $name) {
         if ($uid != db_get_first_id()) {
             $_usergroups->attach(form_input_list_entry($uid, false, $name));
         }
     }
     require_lang('dates');
     $fields->attach(form_input_list(do_lang_tempcode('_USERGROUP'), '', 'group_id', $_usergroups, NULL, false, true));
     $fields->attach(form_input_integer(do_lang_tempcode('_MINUTES'), do_lang_tempcode('DESCRIPTION_GROUPMT_MINUTES'), 'num_minutes', 60, true));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_group_member_timeouts'), '_SELF');
     $submit_name = do_lang_tempcode('ADD');
     $form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name));
     return do_template('RESULTS_TABLE_SCREEN', array('TITLE' => $title, 'RESULTS_TABLE' => $results_table, 'FORM' => $form));
 }
Esempio n. 19
0
/**
 * Relay an error message, if appropriate, to e-mail listeners (sometimes ocProducts, and site staff).
 *
 * @param  string			A error message (in HTML)
 * @param  boolean		Also send to ocProducts
 * @param  ID_TEXT		The notification type
 */
function relay_error_notification($text, $ocproducts = true, $notification_type = 'error_occurred')
{
    // Make sure we don't send too many error emails
    if (function_exists('get_value') && $GLOBALS['BOOTSTRAPPING'] == 0 && array_key_exists('SITE_DB', $GLOBALS) && !is_null($GLOBALS['SITE_DB'])) {
        $num = intval(get_value('num_error_mails_' . date('Y-m-d'))) + 1;
        if ($num == 51) {
            return;
        }
        // We've sent too many error mails today
        $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'values WHERE the_name LIKE \'' . db_encode_like('num\\_error\\_mails\\_%') . '\'');
        persistant_cache_delete('VALUES');
        set_value('num_error_mails_' . date('Y-m-d'), strval($num));
    }
    if (!function_exists('require_lang')) {
        return;
    }
    require_code('urls');
    require_code('tempcode');
    $error_url = running_script('index') ? static_evaluate_tempcode(build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true)) : get_self_url_easy();
    require_code('notifications');
    require_code('comcode');
    $mail = do_lang('ERROR_MAIL', comcode_escape($error_url), str_replace(array('[html', '[/html'), array('&#91;html', '&#91;/html'), $text), NULL, get_site_default_lang());
    dispatch_notification($notification_type, NULL, do_lang('ERROR_OCCURRED_SUBJECT', get_page_name(), NULL, NULL, get_site_default_lang()), $mail, NULL, A_FROM_SYSTEM_PRIVILEGED);
    if ($ocproducts && get_option('send_error_emails_ocproducts', true) == '1' && !running_script('cron_bridge') && strpos($text, '_custom/') === false && strpos($text, 'data/occle.php') === false && strpos($text, '/mini') === false && strpos($text, 'A transaction for the wrong IPN e-mail went through') === false && strpos($text, 'has been disabled for security reasons') === false && strpos($text, 'max_questions') === false && strpos($text, 'Error at offset') === false && strpos($text, 'Unable to allocate memory for pool') === false && strpos($text, 'Out of memory') === false && strpos($text, 'Disk is full writing') === false && strpos($text, 'Disk quota exceeded') === false && strpos($text, 'from storage engine') === false && strpos($text, 'Lost connection to MySQL server') === false && strpos($text, 'Unable to save result set') === false && strpos($text, '.MYI') === false && strpos($text, 'MySQL server has gone away') === false && strpos($text, 'Incorrect key file') === false && strpos($text, 'Too many connections') === false && strpos($text, 'marked as crashed and should be repaired') === false && strpos($text, 'connect to') === false && strpos($text, 'Access denied for') === false && strpos($text, 'Unknown database') === false && strpos($text, 'headers already sent') === false && preg_match('#Maximum execution time of \\d+ seconds#', $text) == 0 && preg_match('#Out of memory \\(allocated (1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24)\\d{6}\\)#', $text) == 0 && strpos($text, 'is marked as crashed and last') === false && strpos($text, 'failed to open stream: Permission denied') === false && strpos($text, 'phpinfo() has been disabled') === false && (strpos($text, 'Maximum execution time') === false || strpos($text, '/js_') === false && strpos($text, '/caches_filesystem.php') === false && strpos($text, '/files2.php') === false) && (strpos($text, 'doesn\'t exist') === false || strpos($text, 'import') === false) && (strpos($text, 'No such file or directory') === false || strpos($text, 'admin_setupwizard') === false) && strpos($text, 'File(/tmp/) is not within the allowed path') === false) {
        require_code('mail');
        mail_wrap(do_lang('ERROR_OCCURRED_SUBJECT', get_page_name(), NULL, NULL, get_site_default_lang()) . ' ' . ocp_version_full(), $mail, array('errors_final' . strval(ocp_version()) . '@ocportal.com'), '', '', '', 3, NULL, true, NULL, true);
    }
    if ($ocproducts && !is_null(get_value('agency_email_address'))) {
        require_code('mail');
        $agency_email_address = get_value('agency_email_address');
        mail_wrap(do_lang('ERROR_OCCURRED_SUBJECT', get_page_name(), NULL, NULL, get_site_default_lang()) . ' ' . ocp_version_full(), $mail, array($agency_email_address), '', '', '', 3, NULL, true, NULL, true);
    }
}
Esempio n. 20
0
// If we are referencing this file in order to extract dependant url's from a pack
handle_self_referencing_embedment();
// Requirements check
$phpv = phpversion();
if (substr($phpv, 0, 2) == '3.') {
    exit(do_lang('PHP_OLD'));
}
if (substr($phpv, 0, 3) == '4.0') {
    exit(do_lang('PHP_OLD'));
}
if (ini_get('file_uploads') == '0') {
    exit(do_lang('NO_UPLOAD'));
}
// Set up some globals
$minor = ocp_version_minor();
$VERSION = strval(ocp_version());
if ($minor != '') {
    $VERSION .= (is_numeric($minor[0]) ? '.' : '-') . $minor;
}
$CHMOD_ARRAY = get_chmod_array();
$password_prompt = new ocp_tempcode();
if (!array_key_exists('step', $_GET)) {
    $_GET['step'] = '1';
}
if (intval($_GET['step']) == 1) {
    $content = step_1();
}
if (intval($_GET['step']) == 2) {
    $content = step_2();
}
if (intval($_GET['step']) == 3) {
Esempio n. 21
0
/**
 * Get all the award selection fields for a content type and content ID
 *
 * @param  ID_TEXT		The content type
 * @param  ?ID_TEXT		The content ID (NULL: not added yet - therefore can't be holding the award yet)
 * @return tempcode		The fields
 */
function get_award_fields($content_type, $id = NULL)
{
    require_code('form_templates');
    $fields = new ocp_tempcode();
    $rows = $GLOBALS['SITE_DB']->query_select('award_types', array('*'), array('a_content_type' => $content_type));
    require_lang('awards');
    foreach ($rows as $row) {
        if (has_category_access(get_member(), 'award', strval($row['id']))) {
            if (!is_null($id)) {
                $test = $GLOBALS['SITE_DB']->query_value_null_ok('award_archive', 'content_id', array('a_type_id' => $row['id']), 'ORDER BY date_and_time DESC');
                $has_award = $test === $id;
            } else {
                $has_award = get_param_integer('award', NULL) === $row['id'];
            }
            $fields->attach(form_input_tick(get_translated_text($row['a_title']), get_translated_text($row['a_description']) == '' ? new ocp_tempcode() : do_lang_tempcode('PRESENT_AWARD', get_translated_tempcode($row['a_description'])), 'award_' . strval($row['id']), $has_award));
        }
    }
    if (!$fields->is_empty()) {
        $help = paragraph(do_lang_tempcode('AWARDS_AFTER_VALIDATION'));
        if (get_option('show_docs') == '1') {
            $help->attach(paragraph(symbol_tempcode('URLISE_LANG', array(do_lang('TUTORIAL_ON_THIS'), brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_featured', 'tut_featured', '1'))));
        }
        $_fields = do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null(get_param_integer('award', NULL)), 'TITLE' => do_lang_tempcode('AWARDS'), 'HELP' => protect_from_escaping($help)));
        $_fields->attach($fields);
        $fields = $_fields;
    }
    return $fields;
}