コード例 #1
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('downloads')) {
         return new ocp_tempcode();
     }
     require_lang('downloads');
     require_code('downloads_stats');
     $bits = new ocp_tempcode();
     if (get_option('downloads_show_stats_count_total', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'ff2bd884d88ddc8c5a81cff897f99a5a', 'KEY' => do_lang_tempcode('COUNT_TOTAL'), 'VALUE' => integer_format(get_num_archive_downloads()))));
     }
     if (get_option('downloads_show_stats_count_archive', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '3d221f2145581a3af51c8948f28b7ac7', 'KEY' => do_lang_tempcode('COUNT_ARCHIVE'), 'VALUE' => get_download_archive_size())));
     }
     if (get_option('downloads_show_stats_count_downloads', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '47c544ef053f9be47e2c48c3a694da1c', 'KEY' => do_lang_tempcode('COUNT_DOWNLOADS'), 'VALUE' => integer_format(get_num_downloads_downloaded()))));
     }
     if (get_option('downloads_show_stats_count_bandwidth', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'b2589ae83652953ece220267043d75c9', 'KEY' => do_lang_tempcode('COUNT_BANDWIDTH'), 'VALUE' => clean_file_size(get_download_bandwidth()))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $files = do_template('BLOCK_SIDE_STATS_SECTION', array('_GUID' => '99ae3f35b3e5eda18901e97ac385d99c', 'SECTION' => do_lang_tempcode('SECTION_DOWNLOADS'), 'CONTENT' => $bits));
     return $files;
 }
コード例 #2
0
ファイル: backup_size.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     require_code('files');
     require_code('files2');
     $size = 0;
     $max_size = get_param_integer('max_size') * 1024 * 1024;
     $files = get_directory_contents(get_custom_file_base());
     foreach ($files as $file) {
         $filesize = filesize(get_custom_file_base() . '/' . $file);
         if ($filesize < $max_size) {
             $size += $filesize;
         }
     }
     return make_string_tempcode(clean_file_size($size));
 }
コード例 #3
0
ファイル: stats_filedump.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('filedump')) {
         return new ocp_tempcode();
     }
     if (!file_exists(get_custom_file_base() . '/uploads/filedump')) {
         return new ocp_tempcode();
     }
     require_lang('filedump');
     require_code('files2');
     $bits = new ocp_tempcode();
     if (get_option('filedump_show_stats_count_total_files', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('COUNT_FILES'), 'VALUE' => integer_format(count(get_directory_contents(get_custom_file_base() . '/uploads/filedump'))))));
     }
     if (get_option('filedump_show_stats_count_total_space', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('DISK_USAGE'), 'VALUE' => clean_file_size(get_directory_size(get_custom_file_base() . '/uploads/filedump')))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('FILE_DUMP'), 'CONTENT' => $bits));
     return $section;
 }
コード例 #4
0
ファイル: files.php プロジェクト: erico-deh/ocPortal
/**
 * Format the specified filesize.
 *
 * @param  integer		The number of bytes the file has
 * @return string			The formatted-string file size
 */
function clean_file_size($bytes)
{
    if ($bytes < 0) {
        return '-' . clean_file_size(-$bytes);
    }
    if (is_null($bytes)) {
        return do_lang('UNKNOWN') . ' bytes';
    }
    if (floatval($bytes) > 2.0 * 1024.0 * 1024.0 * 1024.0) {
        return strval(intval(round(floatval($bytes) / 1024.0 / 1024.0 / 1024.0))) . ' Gb';
    }
    if (floatval($bytes) > 1024.0 * 1024.0 * 1024.0) {
        return float_format(round(floatval($bytes) / 1024.0 / 1024.0 / 1024.0, 2)) . ' Gb';
    }
    if (floatval($bytes) > 2.0 * 1024.0 * 1024.0) {
        return strval(intval(round(floatval($bytes) / 1024.0 / 1024.0))) . ' Mb';
    }
    if (floatval($bytes) > 1024.0 * 1024.0) {
        return float_format(round(floatval($bytes) / 1024.0 / 1024.0, 2)) . ' Mb';
    }
    if (floatval($bytes) > 2.0 * 1024.0) {
        return strval(intval(round(floatval($bytes) / 1024.0))) . ' Kb';
    }
    if (floatval($bytes) > 1024.0) {
        return float_format(round(floatval($bytes) / 1024.0, 2)) . ' Kb';
    }
    return strval($bytes) . ' Bytes';
}
コード例 #5
0
ファイル: ipb3.php プロジェクト: erico-deh/ocPortal
 /**
  * Get an array of topics in the given forum. Each topic is an array with the following attributes:
  * - id, the topic ID
  * - title, the topic title
  * - lastusername, the username of the last poster
  * - lasttime, the timestamp of the last reply
  * - closed, a Boolean for whether the topic is currently closed or not
  * - firsttitle, the title of the first post
  * - firstpost, the first post (only set if $show_first_posts was true)
  *
  * @param  mixed			The forum name or an array of forum IDs
  * @param  integer		The limit
  * @param  integer		The start position
  * @param  integer		The total rows (not a parameter: returns by reference)
  * @param  SHORT_TEXT	The topic title filter
  * @param  boolean		Whether to show the first posts
  * @param  string			The date key to sort by
  * @set    lasttime firsttime
  * @param  boolean		Whether to limit to hot topics
  * @param  SHORT_TEXT	The topic description filter
  * @return ?array			The array of topics (NULL: error)
  */
 function show_forum_topics($name, $limit, $start, &$max_rows, $filter_topic_title = '', $show_first_posts = false, $date_key = 'lasttime', $hot = false, $filter_topic_description = '')
 {
     require_code('xhtml');
     if (is_integer($name)) {
         $id_list = 'forum_id=' . strval((int) $name);
     } elseif (!is_array($name)) {
         if ($name == '<announce>' || is_null($name)) {
             $id_list = '(forum_id IS NULL)';
         } else {
             $id = $this->forum_id_from_name($name);
             if (is_null($id)) {
                 return NULL;
             }
             $id_list = 'forum_id=' . strval((int) $id);
         }
     } else {
         $id_list = '';
         $id_list_2 = '';
         foreach (array_keys($name) as $id) {
             if ($id_list != '') {
                 $id_list .= ' OR ';
             }
             if (is_null($id) || $id == '') {
                 $id_list .= '(forum_id IS NULL)';
             } else {
                 $id_list .= 'forum_id=' . strval((int) $id);
             }
         }
         if ($id_list == '') {
             return NULL;
         }
     }
     $topic_filter = $filter_topic_title != '' ? 'AND title LIKE \'' . db_encode_like($this->ipb_escape($filter_topic_title)) . '\'' : '';
     if ($filter_topic_description != '') {
         $topic_filter .= ' AND description LIKE \'' . db_encode_like($this->ipb_escape($filter_topic_description)) . '\'';
     }
     $rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'topics WHERE (' . $id_list . ') ' . $topic_filter . ' ORDER BY ' . ($date_key == 'lasttime' ? 'last_post' : 'start_date') . ' DESC', $limit, $start);
     $max_rows = $this->connection->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $this->connection->get_table_prefix() . 'topics WHERE (' . $id_list . ') ' . $topic_filter);
     $emoticons_set_dir = $this->get_emo_dir();
     $out = array();
     foreach ($rows as $i => $r) {
         $out[$i] = array();
         $out[$i]['id'] = $r['tid'];
         $out[$i]['num'] = $r['posts'];
         $out[$i]['title'] = $this->ipb_unescape($r['title']);
         $out[$i]['firstusername'] = $this->ipb_unescape($r['starter_name']);
         $out[$i]['lastusername'] = $this->ipb_unescape($r['last_poster_name']);
         $out[$i]['firstmemberid'] = $r['starter_id'];
         $out[$i]['lastmemberid'] = $r['last_poster_id'];
         $out[$i]['firsttime'] = $r['start_date'];
         $out[$i]['lasttime'] = $r['last_post'];
         $out[$i]['closed'] = $r['state'] == 'closed';
         $fp_rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'posts WHERE post NOT LIKE \'' . db_encode_like(do_lang('SPACER_POST', '', '', '', get_site_default_lang()) . '%') . '\' AND topic_id=' . strval((int) $out[$i]['id']) . ' ORDER BY post_date', 1);
         if (!array_key_exists(0, $fp_rows)) {
             unset($out[$i]);
             continue;
         }
         $out[$i]['firsttitle'] = $this->ipb_unescape($fp_rows[0]['post_title']);
         if ($show_first_posts) {
             $post_id = $fp_rows[0]['pid'];
             $post = $fp_rows[0]['post'];
             if (array_key_exists('post_htmlstate', $fp_rows[0]) && $fp_rows[0]['post_htmlstate'] != 0) {
                 if ($fp_rows[0]['post_htmlstate'] == 1) {
                     $post = str_replace('<br />', '', $post);
                 }
                 $post = @html_entity_decode($post, ENT_QUOTES, get_charset());
             }
             $post = preg_replace('#public/style_emoticons/<\\#EMO_DIR\\#>(.+?)\'#is', $emoticons_set_dir . '\\1\'', $post);
             $post = str_replace("class='quotetop'", "class='comcode_quote_h4'", $post);
             $post = str_replace("class='quotemain'", "class='comcode_quote_content'", $post);
             // Attachments
             $attachments = $this->connection->query_select('attachments', array('attach_member_id', 'attach_id', 'attach_file', 'attach_location', 'attach_thumb_location', 'attach_is_image', 'attach_filesize', 'attach_hits'), array('attach_post_key' => $fp_rows[0]['post_key']));
             foreach ($attachments as $attachment) {
                 if ($attachment['attach_thumb_location'] != '' || $attachment['attach_is_image'] == 0) {
                     $url = get_forum_base_url() . '/index.php?act=Attach&type=post&id=' . $attachment['attach_id'];
                     if ($attachment['attach_thumb_location'] != '') {
                         $special = do_template('FORUM_ATTACHMENT_IMAGE_THUMB', array('_GUID' => '98a66462f270f53101c4c0a1b63f0bfc', 'FULL' => $url, 'URL' => get_forum_base_url() . '/uploads/' . $attachment['attach_thumb_location']));
                     } else {
                         $special = do_template('FORUM_ATTACHMENT_LINK', array('_GUID' => '002a3220f35debbe567ce7a225aa221e', 'FULL' => $url, 'FILENAME' => $attachment['attach_file'], 'CLEAN_SIZE' => clean_file_size($attachment['attach_filesize']), 'NUM_DOWNLOADS' => integer_format($attachment['attach_hits'])));
                     }
                 } else {
                     $special = do_template('FORUM_ATTACHMENT_IMAGE', array('_GUID' => '49dbf65cb5e20340a5ad4379ea6344c3', 'URL' => get_forum_base_url() . '/uploads/' . $attachment['attach_location']));
                 }
                 // See if we have to place it somewhere special inside the post
                 $old_post = $post;
                 $post = str_replace('[attachmentid=' . $attachment['attach_id'] . ']', $special->evaluate(), $post);
                 if ($old_post == $post) {
                     $post .= $special->evaluate();
                 }
             }
             global $LAX_COMCODE;
             $end = 0;
             while (($pos = strpos($post, '[right]', $end)) !== false) {
                 $e_pos = strpos($post, '[/right]', $pos);
                 if ($e_pos === false) {
                     break;
                 }
                 $end = $e_pos + strlen('[/right]');
                 $segment = substr($post, $pos, $end - $pos);
                 $temp = $LAX_COMCODE;
                 $LAX_COMCODE = true;
                 $comcode = comcode_to_tempcode($segment, $r['starter_id']);
                 $LAX_COMCODE = $temp;
                 $post = substr($post, 0, $pos) . $comcode->evaluate() . substr($post, $end);
             }
             $temp = $LAX_COMCODE;
             $LAX_COMCODE = true;
             $out[$i]['firstpost'] = comcode_to_tempcode(xhtmlise_html($post), $r['starter_id'], false, 60, NULL, NULL, false, false, true);
             // Assumes HTML for posts
             $LAX_COMCODE = $temp;
         }
     }
     if (count($out) != 0) {
         return $out;
     }
     return NULL;
 }
コード例 #6
0
ファイル: cms_banners.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'id ASC', true);
     list($sortable, $sort_order) = array(substr($current_ordering, 0, strrpos($current_ordering, ' ')), substr($current_ordering, strrpos($current_ordering, ' ') + 1));
     $sortables = array('id' => do_lang_tempcode('CODENAME'), 't_is_textual' => do_lang_tempcode('BANNER_IS_TEXTUAL'), 't_image_width' => do_lang_tempcode('WIDTH'), 't_image_height' => do_lang_tempcode('HEIGHT'), 't_max_file_size' => do_lang_tempcode('_FILE_SIZE'), 't_comcode_inline' => do_lang_tempcode('COMCODE_INLINE'));
     if (db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) {
         $sortables['(SELECT COUNT(*) FROM ' . get_table_prefix() . 'banners WHERE b_type=r.id)'] = do_lang_tempcode('COUNT_TOTAL');
     }
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sort';
     $header_row = results_field_title(array(do_lang_tempcode('CODENAME'), do_lang_tempcode('BANNER_IS_TEXTUAL'), do_lang_tempcode('WIDTH'), do_lang_tempcode('HEIGHT'), do_lang_tempcode('_FILE_SIZE'), do_lang_tempcode('COMCODE_INLINE'), do_lang_tempcode('COUNT_TOTAL'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $total = integer_format($GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)', array('b_type' => $row['id'])));
         $fields->attach(results_entry(array($row['id'] == '' ? do_lang('GENERAL') : $row['id'], $row['t_is_textual'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), integer_format($row['t_image_width']), integer_format($row['t_image_height']), clean_file_size($row['t_max_file_size'] * 1024), $row['t_comcode_inline'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $total, protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . $row['id']))), true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', get_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
コード例 #7
0
ファイル: symbols.php プロジェクト: erico-deh/ocPortal
/**
 * 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;
}
コード例 #8
0
ファイル: filedump.php プロジェクト: erico-deh/ocPortal
 /**
  * The main user interface for the file dump.
  *
  * @return tempcode	The UI.
  */
 function module_do_gui()
 {
     $title = get_page_title('FILE_DUMP');
     $place = filter_naughty(get_param('place', '/'));
     if (substr($place, -1, 1) != '/') {
         $place .= '/';
     }
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place;
     // Show tree
     $dirs = explode('/', substr($place, 0, strlen($place) - 1));
     $i = 0;
     $pre = '';
     $file_tree = new ocp_tempcode();
     while (array_key_exists($i, $dirs)) {
         if ($i > 0) {
             $d = $dirs[$i];
         } else {
             $d = do_lang('FILE_DUMP');
         }
         if (array_key_exists($i + 1, $dirs)) {
             $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF');
             if (!$file_tree->is_empty()) {
                 $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6')));
             }
             $file_tree->attach(hyperlink($tree_url, $d));
         }
         $pre .= $dirs[$i] . '/';
         $i++;
     }
     if (!$file_tree->is_empty()) {
         breadcrumb_add_segment($file_tree, $d);
     } else {
         breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d)));
     }
     // Check directory exists
     $fullpath = get_custom_file_base() . '/uploads/filedump' . $place;
     if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) {
         if (has_specific_permission(get_member(), 'upload_filedump')) {
             @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath))));
             fix_permissions($fullpath, 0777);
             sync_file($fullpath);
         }
     }
     // Find all files in the incoming directory
     $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place);
     $i = 0;
     $filename = array();
     $description = array();
     $filesize = array();
     $filetime = array();
     $directory = array();
     $deletable = array();
     while (false !== ($file = readdir($handle))) {
         if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) {
             $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             $filename[$i] = $directory[$i] ? $file . '/' : $file;
             if ($directory[$i]) {
                 $filesize[$i] = do_lang_tempcode('NA_EM');
             }
             $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place));
             if (!array_key_exists(0, $dbrows)) {
                 $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM');
             } else {
                 $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description'])));
             }
             if ($description[$i]->is_empty()) {
                 $description[$i] = do_lang_tempcode('NONE_EM');
             }
             $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump');
             if ($directory[$i]) {
                 $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = NULL;
             } else {
                 $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             }
             $filesize[$i] = clean_file_size($size);
             $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp);
             $i++;
         }
     }
     closedir($handle);
     if ($i != 0) {
         require_code('templates_table_table');
         $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS')));
         $rows = new ocp_tempcode();
         for ($a = 0; $a < $i; $a++) {
             if ($directory[$a]) {
                 $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF');
             } else {
                 $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a])));
             }
             if (!$directory[$a]) {
                 if ($deletable[$a]) {
                     $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF');
                     $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '9b91e485d80417b1664145f9bca5a2f5', 'NAME' => $filename[$a], 'URL' => $delete_url));
                 } else {
                     $actions = new ocp_tempcode();
                 }
             } else {
                 $delete_url = build_url(array('page' => '_SELF', 'type' => 'ec', 'file' => $filename[$a], 'place' => $place), '_SELF');
                 $actions = do_template('TABLE_TABLE_ACTION_DELETE_CATEGORY', array('_GUID' => '0fa7d4090c6195328191399a14799169', 'NAME' => $filename[$a], 'URL' => $delete_url));
             }
             $rows->attach(table_table_row(array(hyperlink($link, escape_html($filename[$a]), !$directory[$a]), escape_html($description[$a]), escape_html($filesize[$a]), is_null($filetime[$a]) ? do_lang_tempcode('NA') : make_string_tempcode(escape_html($filetime[$a])), $actions)));
         }
         $files = do_template('TABLE_TABLE', array('_GUID' => '1c0a91d47c5fc8a7c2b35c7d9b36132f', 'HEADER_ROW' => $header_row, 'ROWS' => $rows));
     } else {
         $files = new ocp_tempcode();
     }
     // Do a form so people can upload their own stuff
     if (has_specific_permission(get_member(), 'upload_filedump')) {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'uploading' => 1), '_SELF');
         $submit_name = do_lang_tempcode('FILEDUMP_UPLOAD');
         $max = floatval(get_max_file_size());
         $text = new ocp_tempcode();
         if ($max < 30.0) {
             $config_url = get_upload_limit_config_url();
             $text->attach(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max / 1024.0 / 1024.0)), escape_html(is_null($config_url) ? '' : $config_url)));
         }
         require_code('form_templates');
         $fields = form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('_DESCRIPTION_UPLOAD'), 'file', true);
         $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', '', false));
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('place', $place));
         handle_max_file_size($hidden);
         $upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'HIDDEN' => $hidden, 'TEXT' => $text, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $upload_form = new ocp_tempcode();
     }
     // Do a form so people can make folders
     if (get_option('is_on_folder_create') == '1') {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ac'), '_SELF');
         require_code('form_templates');
         $fields = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', '', true);
         $hidden = form_input_hidden('place', $place);
         $submit_name = do_lang_tempcode('FILEDUMP_CREATE_FOLDER');
         $create_folder_form = do_template('FORM', array('_GUID' => '043f9b595d3699b7d8cd7f2284cdaf98', 'TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'SECONDARY_FORM' => true, 'HIDDEN' => $hidden, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $create_folder_form = new ocp_tempcode();
     }
     return do_template('FILE_DUMP_SCREEN', array('_GUID' => '3f49a8277a11f543eff6488622949c84', 'TITLE' => $title, 'PLACE' => $place, 'FILES' => $files, 'UPLOAD_FORM' => $upload_form, 'CREATE_FOLDER_FORM' => $create_folder_form));
 }
コード例 #9
0
ファイル: admin_config.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to edit a configuration page.
  *
  * @return tempcode		The UI
  */
 function config_category()
 {
     require_javascript('javascript_validation');
     /*$GLOBALS['HELPER_PANEL_PIC']='pagepics/config';
     		$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_adv_configuration';*/
     $page = get_param('id');
     $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false);
     $post_url = build_url(array('page' => '_SELF', 'type' => 'set', 'id' => $page, 'redirect' => get_param('redirect', NULL)), '_SELF');
     $category_description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $page);
     $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page));
     // Addin special ones
     if ($page == 'SITE') {
         $rows[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0);
     }
     /*global $M_SORT_KEY;	This is a lame sort - it doesn't preserve internal order
     		$M_SORT_KEY='section';
     		usort($rows,'multi_sort');*/
     // Better sort
     $all_known_groups = array();
     foreach ($rows as $myrow) {
         $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false);
         if (is_null($_group)) {
             $_group = $myrow['section'];
         }
         $_group = strtolower(trim(preg_replace('#(&.*;)|[^\\w\\d\\s]#U', '', $_group)));
         if (array_key_exists($_group, $all_known_groups) && $all_known_groups[$_group] != $myrow['section']) {
             $_group = 'std_' . $myrow['section'];
         }
         // If cat names translate to same things or are in non-latin characters like Cyrillic
         $all_known_groups[$_group] = $myrow['section'];
     }
     $old_rows = $rows;
     $rows = array();
     ksort($all_known_groups);
     foreach ($all_known_groups as $group_codename) {
         foreach ($old_rows as $myrow) {
             if ($myrow['section'] == $group_codename) {
                 $rows[] = $myrow;
             }
         }
     }
     // Move advanced group options to the end
     $rows2 = array();
     foreach ($rows as $i => $row) {
         if ($row['section'] == 'ADVANCED') {
             $rows2[] = $row;
             unset($rows[$i]);
         }
     }
     $rows = array_merge($rows, $rows2);
     // UI hooks
     $ui_hooks = find_all_hooks('modules', 'admin_config');
     $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize')));
     $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size')));
     $groups = new ocp_tempcode();
     require_code('form_templates');
     $current_group = '';
     $out = '';
     $_groups = array();
     foreach ($rows as $myrow) {
         if ($myrow['eval'] != '' && $myrow['the_name'] != 'detect_lang_forum') {
             if (defined('HIPHOP_PHP')) {
                 require_code('hooks/systems/config_default/' . $myrow['the_name']);
                 $hook = object_factory('Hook_config_default_' . $myrow['the_name']);
                 if (is_null($hook->get_default())) {
                     continue;
                 }
             } else {
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 10;
                 // LEGACY Workaround for corrupt webhost installers
                 if (is_null(@eval($myrow['eval'] . ';'))) {
                     continue;
                 }
                 // @'d in case default is corrupt, don't want it to give errors forever
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 0;
                 // LEGACY
             }
         }
         $_group = do_lang($myrow['section'], NULL, NULL, NULL, NULL, false);
         $name = do_lang($myrow['human_name'], NULL, NULL, NULL, NULL, false);
         $_group_tempcode = is_null($_group) ? make_string_tempcode($myrow['section']) : do_lang_tempcode($myrow['section']);
         $name_tempcode = is_null($name) ? make_string_tempcode($myrow['human_name']) : do_lang_tempcode($myrow['human_name']);
         if (get_forum_type() == 'ocf' && $myrow['explanation'] == 'CONFIG_OPTION_forum_in_portal') {
             $exp_string = $myrow['explanation'] . '__ocf';
         } else {
             $exp_string = $myrow['explanation'];
         }
         $_explanation = do_lang($exp_string, NULL, NULL, NULL, NULL, false);
         if (is_null($_explanation)) {
             $_explanation = do_lang('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section'], NULL, NULL, NULL, NULL, false);
             if (is_null($_explanation)) {
                 $explanation = new ocp_tempcode();
             } else {
                 $explanation = do_lang_tempcode('CONFIG_GROUP_DEFAULT_DESCRIP_' . $myrow['section']);
             }
         } else {
             $explanation = do_lang_tempcode($exp_string);
         }
         if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) {
             continue;
         }
         if ($myrow['section'] != $current_group && $current_group != '') {
             $_current_group = do_lang_tempcode($current_group);
             $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
             if (is_null($_group_description)) {
                 $group_description = new ocp_tempcode();
             } else {
                 $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize));
             }
             $group = do_template('CONFIG_GROUP', array('_GUID' => 'af4c31daa1bc39714ab83b11bd6d3e51', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_current_group));
             $groups->attach($group->evaluate());
             $out = '';
         }
         $_groups[$myrow['section']] = $_group_tempcode;
         switch ($myrow['the_type']) {
             case 'special':
                 switch ($myrow['the_name']) {
                     case 'timezone':
                         $list = '';
                         $timezone = get_site_timezone();
                         foreach (get_timezone_list() as $_timezone => $timezone_nice) {
                             $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice));
                         }
                         $out .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('TIME_ZONE'), do_lang_tempcode('DESCRIPTION_TIMEZONE_SITE'), 'timezone', make_string_tempcode($list)));
                         break;
                     default:
                         require_code('hooks/modules/admin_config/' . filter_naughty_harsh($myrow['the_name']));
                         $hook_ob = object_factory('Hook_admin_config_' . filter_naughty_harsh($myrow['the_name']));
                         $out .= static_evaluate_tempcode($hook_ob->run($myrow));
                         break;
                 }
                 break;
             case 'integer':
                 $out .= static_evaluate_tempcode(form_input_integer($name_tempcode, $explanation, $myrow['the_name'], intval(get_option($myrow['the_name'])), false));
                 break;
             case 'line':
                 if (strpos($myrow['the_name'], 'colour') !== false && substr(get_option($myrow['the_name']), 0, 1) == '#') {
                     $out .= static_evaluate_tempcode(form_input_colour($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 } elseif ($myrow['the_name'] == 'currency') {
                     $list = '';
                     require_code('currency');
                     $currencies = array_keys(get_currency_map());
                     foreach ($currencies as $currency) {
                         $list .= static_evaluate_tempcode(form_input_list_entry($currency, $currency == get_option($myrow['the_name'])));
                     }
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list)));
                 } elseif ($myrow['the_name'] == 'payment_gateway') {
                     $list = '';
                     $all_via = find_all_hooks('systems', 'ecommerce_via');
                     foreach (array_keys($all_via) as $via) {
                         $list .= static_evaluate_tempcode(form_input_list_entry($via, $via == get_option($myrow['the_name'])));
                     }
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list)));
                 } else {
                     /*if (strpos($myrow['the_name'],'password')!==false)  password fields can't take defaults
                     			$out.=static_evaluate_tempcode(form_input_password($name_tempcode,$explanation,$myrow['the_name'],get_option($myrow['the_name']),false));
                     		else
                     			*/
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'list':
                 $list = '';
                 $_value = get_option($myrow['the_name']);
                 $values = explode('|', $myrow['c_data']);
                 foreach ($values as $value) {
                     $_option_text = do_lang('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value, NULL, NULL, NULL, NULL, false);
                     if (!is_null($_option_text)) {
                         $option_text = do_lang_tempcode('CONFIG_OPTION_' . $myrow['the_name'] . '_VALUE_' . $value);
                     } else {
                         $option_text = make_string_tempcode($value);
                     }
                     $list .= static_evaluate_tempcode(form_input_list_entry($value, $_value == $value, $option_text));
                 }
                 $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], make_string_tempcode($list), NULL, false, false));
                 break;
             case 'transline':
                 $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 break;
             case 'text':
                 $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 break;
             case 'transtext':
                 $out .= static_evaluate_tempcode(form_input_text($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false, NULL, true));
                 break;
             case 'float':
                 $out .= static_evaluate_tempcode(form_input_float($name_tempcode, $explanation, $myrow['the_name'], floatval(get_option($myrow['the_name'])), false));
                 break;
             case 'tick':
                 $out .= static_evaluate_tempcode(form_input_tick($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']) == '1'));
                 break;
             case 'date':
                 $out .= static_evaluate_tempcode(form_input_date($name_tempcode, $explanation, $myrow['the_name'], false, false, false, intval(get_option($myrow['the_name'])), 40, intval(date('Y')) - 20, NULL, false));
                 break;
             case 'forum':
             case '?forum':
                 if (get_forum_type() == 'ocf' && addon_installed('ocf_forum')) {
                     $current_setting = get_option($myrow['the_name']);
                     if (!is_numeric($current_setting)) {
                         $_current_setting = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $current_setting));
                         if (is_null($_current_setting)) {
                             if ($myrow['the_type'] == '?forum') {
                                 $current_setting = NULL;
                             } else {
                                 $current_setting = strval(db_get_first_id());
                                 attach_message(do_lang_tempcode('FORUM_CURRENTLY_UNSET', $name_tempcode), 'notice');
                             }
                         } else {
                             $current_setting = strval($_current_setting);
                         }
                     }
                     $out .= static_evaluate_tempcode(form_input_tree_list($name_tempcode, $explanation, $myrow['the_name'], NULL, 'choose_forum', array(), false, $current_setting));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'category':
                 if (get_forum_type() == 'ocf') {
                     $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'id', array('c_title' => get_option($myrow['the_name'])));
                     require_code('ocf_forums2');
                     $_list = ocf_nice_get_categories(NULL, $tmp_value);
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
             case 'usergroup':
                 if (get_forum_type() == 'ocf') {
                     $tmp_value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'g.id', array('text_original' => get_option($myrow['the_name'])));
                     require_code('ocf_groups');
                     $_list = ocf_nice_get_usergroups($tmp_value);
                     $out .= static_evaluate_tempcode(form_input_list($name_tempcode, $explanation, $myrow['the_name'], $_list));
                 } else {
                     $out .= static_evaluate_tempcode(form_input_line($name_tempcode, $explanation, $myrow['the_name'], get_option($myrow['the_name']), false));
                 }
                 break;
         }
         $current_group = $myrow['section'];
     }
     if ($out != '') {
         $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
         if (is_null($_group_description)) {
             $group_description = new ocp_tempcode();
         } else {
             $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $current_group, escape_html($post_max_size), escape_html($upload_max_filesize));
         }
         $group = do_template('CONFIG_GROUP', array('_GUID' => '84c0db86002a33a383a7c2e195dd3913', 'GROUP_DESCRIPTION' => $group_description, 'GROUP_NAME' => $current_group, 'GROUP' => $out, 'CURRENT_GROUP' => $_group_tempcode));
         $groups->attach($group->evaluate());
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CONFIGURATION'))));
     breadcrumb_set_self(do_lang_tempcode('CONFIG_CATEGORY_' . $page));
     return do_template('CONFIG_CATEGORY_SCREEN', array('_GUID' => 'd01b28b71c38bbb52b6aaf877c7f7b0e', 'CATEGORY_DESCRIPTION' => $category_description, '_GROUPS' => $_groups, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'GROUPS' => $groups, 'SUBMIT_NAME' => do_lang_tempcode('SAVE')));
 }
コード例 #10
0
ファイル: admin_themes.php プロジェクト: erico-deh/ocPortal
    /**
     * The UI to edit a template.
     *
     * @return tempcode		The UI
     */
    function _edit_templates()
    {
        $theme = get_param('theme');
        //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
        $title = get_page_title('EDIT_TEMPLATES');
        $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_MARKUP');
        $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_themes';
        // Searching for something, which will provide links that loop back to the proper version of this page
        $search = get_param('search', '', true);
        if ($search != '') {
            $filesarray = $this->get_template_files_array($theme);
            $results = new ocp_tempcode();
            foreach ($filesarray as $file) {
                $full_path = (strpos($file, '/default/templates/') !== false ? get_file_base() : get_custom_file_base()) . '/themes/' . $file;
                $contents = file_get_contents($full_path, FILE_TEXT);
                if (strpos(strtolower($contents), strtolower($search)) !== false || strpos(strtolower($file), strtolower($search)) !== false) {
                    $_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => $file), '_SELF');
                    $results->attach(do_template('INDEX_SCREEN_ENTRY', array('_GUID' => 'ed744a45728f3d7c1082a3dda893f352', 'URL' => $_url, 'NAME' => $file)));
                }
            }
            return do_template('INDEX_SCREEN', array('_GUID' => '286a7ae3add44f935a9a2018dde3ccaf', 'TITLE' => $title, 'PRE' => do_lang_tempcode('_RESULTS'), 'POST' => '', 'CONTENT' => $results));
        }
        require_javascript('javascript_editing');
        $post_url = build_url(array('page' => '_SELF', 'type' => '__edit_templates'), '_SELF');
        $preview_url = get_param('preview_url', '');
        // We support multi-list for getting here, so f0file can be an array, in which case we change that
        if (array_key_exists('f0file', $_GET)) {
            if (is_array($_GET['f0file'])) {
                foreach ($_GET['f0file'] as $i => $f) {
                    $_GET['f' . strval($i) . 'file'] = $f;
                }
            }
        }
        $template_editors = new ocp_tempcode();
        $templates = array();
        $files_seen = array();
        if (get_option('editarea') == '1') {
            $GLOBALS['EXTRA_HEAD']->attach(make_string_tempcode('
				<script language="javascript" type="text/javascript" src="' . get_base_url() . '/data/editarea/edit_area_full.js"></script>
			'));
        }
        $count = 0;
        $first_id = '';
        foreach (array_keys($_GET) as $_i) {
            $matches = array();
            if (preg_match('#f(\\d+)file#', $_i, $matches) != 0) {
                $i = $matches[1];
            } else {
                continue;
            }
            // The file we're editing
            $file = filter_naughty(get_param('f' . $i . 'file', ''));
            if ($file == '') {
                $file = filter_naughty(get_param('f' . $i . 'file2', ''));
            }
            if ($file == '') {
                continue;
            }
            if (substr($file, -4) != '.tpl' && substr($file, -4) != '.css') {
                $file .= '.tpl';
            }
            if (get_param('preview_url', '') == '') {
                if (substr($file, -4) != '.tpl' && substr($file, -4) != '.css') {
                    $file .= '.tpl';
                }
                require_code('lorem');
                $all_previews = find_all_previews__by_template();
                if (array_key_exists(basename($file), $all_previews)) {
                    $_preview_url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => basename($file), 'hook' => $all_previews[basename($file)][0], 'function' => $all_previews[basename($file)][1], 'arg' => '', 'keep_theme' => $theme, 'keep_wide_high' => 1), '_SELF');
                    $preview_url = $_preview_url->evaluate();
                }
            }
            if (in_array($file, $files_seen)) {
                continue;
            }
            $files_seen[] = $file;
            if (!is_null($GLOBALS['CURRENT_SHARE_USER']) && strpos($file, 'BANNER_TYPED') !== false) {
                warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
            }
            if ($file[0] == '!') {
                warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
            }
            $syntax = 'html';
            if (substr($file, -4) == '.css') {
                $syntax = 'css';
            } elseif (substr($file, 0, 11) == 'JAVASCRIPT_') {
                $syntax = 'js';
            }
            if (get_option('editarea') == '1') {
                $GLOBALS['EXTRA_HEAD']->attach('
					<script type="text/javascript">// <![CDATA[
					editAreaLoader.init({
						id : "f' . $i . '_new"
						,syntax: "' . $syntax . '"
						,start_highlight: true
						,language: "' . (file_exists(get_file_base() . '/data/editarea/langs/' . strtolower(user_lang())) ? strtolower(user_lang()) : 'en') . '"
						,allow_resize: true
						,toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, reset_highlight, word_wrap"
					});
					//]]></script>
				');
            }
            if ($file == 'HEADER.tpl') {
                $a = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'FOOTER'), '_SELF');
                $b = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'STYLED_HTML_WRAP'), '_SELF');
                $c = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'BASIC_HTML_WRAP'), '_SELF');
                $d = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'POPUP_HTML_WRAP'), '_SELF');
                $e = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => 'MAIL'), '_SELF');
                attach_message(do_lang_tempcode('HEADER_EDIT_ALSO', escape_html($a->evaluate()), escape_html($b->evaluate()), array(escape_html($c->evaluate()), escape_html($d->evaluate()), escape_html($e->evaluate()))), 'inform');
            }
            // Support searching
            if (strpos($file, '/') === false) {
                $codename = $file;
                if (substr($file, -4) == '.css') {
                    $file = $theme . '/css_custom/' . $codename;
                    if (!file_exists(get_custom_file_base() . '/themes/' . $file)) {
                        $file = 'default/css_custom/' . $codename;
                    }
                    if (!file_exists(get_custom_file_base() . '/themes/' . $file)) {
                        $file = 'default/css/' . $codename;
                    }
                } else {
                    $file = $theme . '/templates_custom/' . $codename;
                    if (!file_exists(get_custom_file_base() . '/themes/' . $file)) {
                        $file = $theme . '/templates/' . $codename;
                    }
                    if (!file_exists(get_custom_file_base() . '/themes/' . $file)) {
                        $file = 'default/templates_custom/' . $codename;
                    }
                    if (!file_exists(get_custom_file_base() . '/themes/' . $file)) {
                        $file = 'default/templates/' . $codename;
                    }
                }
            } else {
                $codename = basename($file);
            }
            // The file we're LOADING from for edit (maybe $file, maybe some old versions being restored)
            $restore_from = filter_naughty(get_param('restore_from', $file));
            if (file_exists(get_file_base() . '/themes/' . $restore_from)) {
                $path = get_file_base() . '/themes/' . $restore_from;
                $contents = file_get_contents($path, FILE_TEXT);
                $last_path = $path;
            } elseif (file_exists(get_custom_file_base() . '/themes/' . $restore_from)) {
                $path = get_custom_file_base() . '/themes/' . $restore_from;
                $contents = file_get_contents($path, FILE_TEXT);
                $last_path = $path;
            } else {
                $contents = '';
                $last_path = NULL;
            }
            // Revision history
            $filesarray = $this->get_template_files_array($theme, basename($file), true);
            rsort($filesarray);
            $j = 0;
            $revision_history = new ocp_tempcode();
            $max = intval(get_option('number_revisions_show'));
            foreach ($filesarray as $time) {
                // Find who did the revision
                $editor = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'the_user', array('date_and_time' => $time, 'the_type' => 'EDIT_TEMPLATES', 'param_a' => $file));
                if (is_null($editor)) {
                    $editor = do_lang('UNKNOWN');
                } else {
                    $editor = $GLOBALS['FORUM_DRIVER']->get_username($editor);
                    if (is_null($editor)) {
                        $editor = do_lang('UNKNOWN');
                    }
                }
                $date = is_null($time) ? do_lang('UNKNOWN') : get_timezoned_date($time);
                $url = get_custom_base_url() . '/themes/' . str_replace('templates/', 'templates_custom/', $file) . '.' . strval($time);
                $old_file = get_custom_file_base() . '/themes/' . str_replace('templates/', 'templates_custom/', $file) . '.' . strval($time);
                if (!file_exists($old_file)) {
                    $url = get_custom_base_url() . '/themes/' . str_replace('default/', $theme . '/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time);
                    $old_file = get_custom_file_base() . '/themes/' . str_replace('default/', $theme . '/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time);
                }
                if (!file_exists($old_file)) {
                    $url = get_custom_base_url() . '/themes/' . str_replace($theme . '/', 'default/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time);
                    $old_file = get_custom_file_base() . '/themes/' . str_replace($theme . '/', 'default/', str_replace('templates/', 'templates_custom/', $file)) . '.' . strval($time);
                }
                $size = filesize($old_file);
                $restore_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => basename($file), 'restore_from' => substr($old_file, strlen(get_custom_file_base() . '/themes/'))), '_SELF');
                require_code('diff');
                if (function_exists('diff_simple')) {
                    $rendered_diff = is_null($last_path) ? '' : diff_simple($old_file, $last_path);
                    $last_path = $old_file;
                    $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'f0cb02bfa3692ed431b69b8d9dc0b2f8', 'RENDERED_DIFF' => $rendered_diff, 'REFERENCE_POINT_EXACT' => true, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size))));
                    $j++;
                }
                if ($j == $max) {
                    break;
                }
            }
            $orig_version = str_replace('/templates_custom/', '/templates/', $file);
            $orig_version = str_replace('/css_custom/', '/css/', $orig_version);
            if (!file_exists(get_file_base() . '/themes/' . $orig_version)) {
                $orig_version = 'default' . substr($orig_version, strpos($orig_version, '/'));
            }
            if ((strpos($file, '/templates_custom/') !== false || strpos($file, '/css_custom/') !== false) && file_exists(get_file_base() . '/themes/' . $orig_version)) {
                $restore_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme, 'f0file' => basename($file), 'restore_from' => $orig_version), '_SELF');
                $url = get_base_url() . '/themes/' . $orig_version;
                $size = filesize(get_custom_file_base() . '/themes/' . $file);
                require_code('diff');
                if (function_exists('diff_simple')) {
                    $rendered_diff = diff_simple(get_file_base() . '/themes/' . $orig_version, $last_path);
                    $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => '7ba03fe98a20330fc64ad742d2fb74fa', 'RENDERED_DIFF' => $rendered_diff, 'REFERENCE_POINT_EXACT' => true, 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size))));
                    $j++;
                }
            }
            if ($j != 0 && get_param('restore_from', '') == '') {
                $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '435e050dd2f38187d757e792ceb2f2f5', 'CONTENT' => $revision_history));
            } elseif ($j != 0) {
                $revision_history = do_template('REVISION_RESTORE');
            }
            $_file = substr($file, strrpos($file, '/') + 1);
            if (substr($_file, -4) == '.css') {
                $old_contents = @file_get_contents(get_file_base() . '/themes/default/css/' . $_file);
            } else {
                $old_contents = @file_get_contents(get_file_base() . '/themes/default/templates/' . $_file, FILE_TEXT);
            }
            if ($old_contents === false) {
                $old_contents = '';
            }
            $matches = array();
            $cnt = preg_match_all('#\\{([\\w_]*)\\}#', $old_contents, $matches);
            $parameters = new ocp_tempcode();
            $p_done = array();
            for ($j = 0; $j < $cnt; $j++) {
                if (array_key_exists($matches[1][$j], $p_done)) {
                    continue;
                }
                $p_done[$matches[1][$j]] = 1;
                $parameters->attach(form_input_list_entry($matches[1][$j] . '__0', false, $matches[1][$j]));
            }
            $parameters = do_template('TEMPLATE_EDIT_SCREEN_DROPDOWN', array('_GUID' => '50f31c49c99b864c1719fb51ed426274', 'ID' => $i, 'PARAMETERS' => $parameters, 'NAME' => 'ppparameter', 'LANG' => do_lang_tempcode('INSERT_PARAMETER')));
            $_directives = array(array('BOX', '1'), array('WHILE', '1'), array('IF_NON_EMPTY', '1'), array('IF_EMPTY', '1'), array('IF', '1'), array('IF_ADJACENT', '1'), array('SHIFT_ENCODE', '1'), array('LOOP', '1'));
            $directives = $this->generate_from($_directives, 'DIRECTIVE', $i);
            $_programmatic_symbols = array(array('RAND', '0'), array('SET_RAND', '0+'), array('CYCLE', '1+'), array('INIT', '1'), array('SET', '2'), array('GET', '1'), array('INC', '1'), array('DEC', '1'), array('SHIFT_DECODE', '1'));
            $programmatic_symbols = $this->generate_from($_programmatic_symbols, 'PROGRAMMATIC_SYMBOL', $i);
            $_abstraction_symbols = array(array('IMG', '1'), array('PAGE_LINK', '1'), array('MAILTO', '0'), array('BLOCK', '2'), array('THUMBNAIL', '2'), array('LOAD_PAGE', '1'), array('LOAD_PANEL', '1'));
            $abstraction_symbols = $this->generate_from($_abstraction_symbols, 'ABSTRACTION_SYMBOL', $i);
            $_symbols = array(array('THEME', '0'), array('LANG', '0'), array('BASE_URL', '0'), array('MOBILE', '0'), array('SITE_NAME', '0'), array('STAFF_ADDRESS', '0'), array('USER', '0'), array('DATE_AND_TIME', '0'), array('DATE', '0'), array('TIME', '0'), array('USERNAME', '0-1'), array('IS_STAFF', '0'), array('MATCH_KEY_MATCH', '1'));
            $symbols = $this->generate_from($_symbols, 'SYMBOL', $i);
            $_arithmetical_symbols = array(array('MAX', '2'), array('MIN', '2'), array('REM', '2'), array('DIV', '2'), array('SUBTRACT', '2'), array('ADD', '2'), array('ROUND', '2'), array('MULT', '2'));
            $arithmetical_symbols = $this->generate_from($_arithmetical_symbols, 'ARITHMETICAL_SYMBOL', $i);
            $_formatting_symbols = array(array('WCASE', '1'), array('LCASE', '1'), array('UCASE', '1'), array('REPLACE', '3'), array('AT', '2'), array('SUBSTR', '3'), array('LENGTH', '1'), array('WORDWRAP', '2'), array('TRUNCATE_LEFT', '2'), array('TRUNCATE_SPREAD', '2'));
            $formatting_symbols = $this->generate_from($_formatting_symbols, 'FORMATTING_SYMBOL', $i);
            $_logical_symbols = array(array('NOT', '1'), array('OR', '2'), array('AND', '2'), array('EQ', '2'), array('NEQ', '2'), array('LT', '2'), array('GT', '2'));
            $logical_symbols = $this->generate_from($_logical_symbols, 'LOGICAL_SYMBOL', $i);
            $guid = get_param('f' . $i . 'guid', '?');
            if ($guid == '?') {
                $guid = '';
            }
            $guids = array();
            $file_bits = explode('/', $file);
            $clean_file = str_replace('.tpl', '', $file_bits[count($file_bits) - 1]);
            $_guids = @unserialize(@file_get_contents(get_file_base() . '/data/guids.dat', FILE_TEXT));
            if ($_guids !== false && array_key_exists($clean_file, $_guids)) {
                foreach ($_guids[$clean_file] as $_guid) {
                    $guids[] = array('FILENAME' => $_guid[0], 'LINE' => integer_format($_guid[1]), 'THIS_GUID' => $_guid[2]);
                }
            }
            $templates[] = array('I' => $i, 'FILE' => $file);
            $display = $count == 0 ? 'block' : 'none';
            if ($count == 0) {
                $first_id = $i;
            }
            $template_editors->attach(do_template('TEMPLATE_EDIT_SCREEN_EDITOR', array('PREVIEW_URL' => $preview_url, 'CODENAME' => str_replace('.tpl', '', $codename), 'I' => $i, 'DISPLAY' => $display, 'GUIDS' => $guids, 'GUID' => $guid, 'ARITHMETICAL_SYMBOLS' => $arithmetical_symbols, 'FORMATTING_SYMBOLS' => $formatting_symbols, 'LOGICAL_SYMBOLS' => $logical_symbols, 'ABSTRACTION_SYMBOLS' => $abstraction_symbols, 'PARAMETERS' => $parameters, 'DIRECTIVES' => $directives, 'PROGRAMMATIC_SYMBOLS' => $programmatic_symbols, 'SYMBOLS' => $symbols, 'FILE' => $file, 'FILE_SAVE_TARGET' => str_replace('default/', $theme . '/', $file), 'OLD_CONTENTS' => $old_contents, 'CONTENTS' => $contents, 'REVISION_HISTORY' => $revision_history)));
            $count++;
        }
        if ($count == 1) {
            $GLOBALS['SEO_TITLE'] = $files_seen[0];
        }
        if ($template_editors->is_empty()) {
            warn_exit(do_lang_tempcode('NO_TEMPLATES_SELECTED'));
        }
        breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')), array('_SELF:_SELF:edit_templates:theme=' . $theme, do_lang_tempcode('CHOOSE'))));
        return do_template('TEMPLATE_EDIT_SCREEN', array('_GUID' => 'cbcd6d18c2456f94f72624e1a39a36a5', 'MULTIPLE' => $count > 1, 'FIRST_ID' => $first_id, 'THEME' => $theme, 'TEMPLATES' => $templates, 'TITLE' => $title, 'URL' => $post_url, 'TEMPLATE_EDITORS' => $template_editors));
    }
コード例 #11
0
ファイル: tempcode.php プロジェクト: erico-deh/ocPortal
/**
 * Certain symbols need preprocessing, before the output stream is made.
 *
 * @param  array			Symbol details
 * @param  array			Where we store children stuff
 */
function handle_symbol_preprocessing($bit, &$children)
{
    switch ($bit[2]) {
        case 'PAGE_LINK':
            $param = $bit[3];
            if (isset($param[0])) {
                if (is_object($param[0])) {
                    $param[0] = $param[0]->evaluate();
                }
                list(, $url_parts, ) = page_link_decode($param[0]);
                if (!isset($url_parts['id']) && !array_key_exists('id', $url_parts)) {
                    return;
                }
                if (!isset($url_parts['type']) && !array_key_exists('type', $url_parts)) {
                    $url_parts['type'] = 'misc';
                }
                if ($url_parts['type'] === NULL) {
                    $url_parts['type'] = 'misc';
                }
                // NULL means "do not take from environment"; so we default it to 'misc' (even though it might actually be left out when SEO URLs are off, we know it cannot be for SEO URLs)
                if (!array_key_exists('page', $url_parts)) {
                    return;
                }
                if ($url_parts['id'] === NULL) {
                    $url_parts['id'] = strval(db_get_first_id());
                }
                // Does this URL arrangement support monikers?
                global $LOADED_MONIKERS;
                if (!isset($LOADED_MONIKERS[$url_parts['page']][$url_parts['type']][$url_parts['id']])) {
                    global $CONTENT_OBS, $LOADED_MONIKERS;
                    load_moniker_hooks();
                    $found = false;
                    $looking_for = '_SEARCH:' . $url_parts['page'] . ':' . $url_parts['type'] . ':_WILD';
                    $ob_info = isset($CONTENT_OBS[$looking_for]) ? $CONTENT_OBS[$looking_for] : NULL;
                    if ($ob_info !== NULL) {
                        $LOADED_MONIKERS[$url_parts['page']][$url_parts['type']][$url_parts['id']] = true;
                    }
                    // Indicator to preload this
                }
            }
            return;
        case 'SET':
            $param = $bit[3];
            if (isset($param[1])) {
                global $TEMPCODE_SETGET;
                $param_copy = array();
                foreach ($param as $i => $x) {
                    if ($i != 0) {
                        $param_copy[] = is_object($x) ? $x->evaluate() : $x;
                    }
                }
                $TEMPCODE_SETGET[is_object($param[0]) ? $param[0]->evaluate() : $param[0]] = implode(',', $param_copy);
                if ($GLOBALS['RECORD_TEMPLATES_TREE'] && is_object($param[1])) {
                    $children[] = array(':set: ' . (is_object($param[0]) ? $param[0]->evaluate() : $param[0]), isset($param[1]->children) ? $param[1]->children : array(), isset($param[1]->fresh) ? $param[1]->fresh : false);
                }
            }
            return;
        case 'BLOCK':
            $param = $bit[3];
            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);
                }
            }
            //if (strpos(serialize($param),'side_stored_menu')!==false) { @debug_print_backtrace();exit(); } // Useful for debugging
            global $REQUEST_BLOCK_NEST_LEVEL;
            global $LOADED_BLOCKS;
            if (isset($LOADED_BLOCKS[serialize($param)])) {
                $REQUEST_BLOCK_NEST_LEVEL--;
                return;
            }
            $REQUEST_BLOCK_NEST_LEVEL++;
            if ($REQUEST_BLOCK_NEST_LEVEL > 20) {
                $REQUEST_BLOCK_NEST_LEVEL = 0;
                $LOADED_BLOCKS[serialize($param)] = do_lang_tempcode('INTERNAL_ERROR');
                attach_message(do_lang_tempcode('STOPPED_RECURSIVE_RESOURCE_INCLUDE', is_string($param[0]) ? $param[0] : 'block'), 'warn');
                return;
            }
            $block_parms = array();
            foreach ($param as $_param) {
                $block_parts = explode('=', $_param, 2);
                if (!isset($block_parts[1])) {
                    $LOADED_BLOCKS[serialize($param)] = do_lang_tempcode('INTERNAL_ERROR');
                    return;
                }
                list($key, $val) = $block_parts;
                $block_parms[$key] = $val;
            }
            if (isset($_GET['keep_show_loading']) && function_exists('memory_get_usage') && $_GET['keep_show_loading'] == '1') {
                $before = memory_get_usage();
            }
            $b_value = do_block($block_parms['block'], $block_parms);
            if (isset($_GET['keep_show_loading']) && function_exists('memory_get_usage') && $_GET['keep_show_loading'] == '1') {
                @ob_end_flush();
                @ob_end_flush();
                @ob_end_flush();
                print '<!-- block: ' . htmlentities($block_parms['block']) . ' (' . clean_file_size(memory_get_usage() - $before) . ' bytes used, now at ' . integer_format(memory_get_usage()) . ') -->' . "\n";
                flush();
            }
            if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                $children[] = array(':block: ' . $block_parms['block'], array(array($b_value->codename, isset($b_value->children) ? $b_value->children : array(), isset($b_value->fresh) ? $b_value->fresh : false)), true);
            }
            $b_value->handle_symbol_preprocessing();
            $LOADED_BLOCKS[serialize($param)] = $b_value;
            $REQUEST_BLOCK_NEST_LEVEL--;
            return;
        case 'JAVASCRIPT_INCLUDE':
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            require_javascript($param[0]);
            return;
        case 'FACILITATE_AJAX_BLOCK_CALL':
            require_javascript('javascript_ajax');
            return;
        case 'CSS_INHERIT':
        case 'CSS_INCLUDE':
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            require_css($param[0]);
            return;
        case 'TRIM':
            $param = $bit[3];
            if (isset($param[0]) && is_object($param[0])) {
                if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                    $param[0]->handle_symbol_preprocessing();
                    $children[] = array(':trim', isset($param[0]->children) ? $param[0]->children : array(), isset($param[0]->fresh) ? $param[0]->fresh : false, true);
                }
            }
            break;
        case 'LOAD_PANEL':
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            global $LOADED_PANELS;
            if (isset($LOADED_PANELS[serialize($param)])) {
                return;
            }
            if (array_key_exists(0, $param)) {
                if (substr(get_page_name(), 0, 6) != 'panel_') {
                    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);
                    }
                    global $ZONE;
                    $wide_high = is_wide_high();
                    $wide = is_wide();
                    if (($wide == 0 || $wide_high == 0 && ($param[0] == 'bottom' || $param[0] == 'top')) && (get_option('site_closed') == '0' || $GLOBALS['IS_ACTUALLY_ADMIN'] || has_specific_permission(get_member(), 'access_closed_site'))) {
                        if (function_exists('memory_get_usage') && isset($_GET['keep_show_loading']) && $_GET['keep_show_loading'] == '1') {
                            $before = memory_get_usage();
                        }
                        $tp_value = request_page('panel_' . $param[0], false, array_key_exists(1, $param) ? $param[1] : NULL, NULL);
                        if (function_exists('memory_get_usage') && isset($_GET['keep_show_loading']) && $_GET['keep_show_loading'] == '1') {
                            @ob_end_flush();
                            @ob_end_flush();
                            @ob_end_flush();
                            print '<!-- panel: ' . htmlentities('panel_' . $param[0]) . ' (' . clean_file_size(memory_get_usage() - $before) . ' bytes used, now at ' . number_format(memory_get_usage()) . ') -->' . "\n";
                            flush();
                        }
                        $tp_value->handle_symbol_preprocessing();
                        if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                            $children[] = array(':panel: ' . $param[0], array(array($tp_value->codename, isset($tp_value->children) ? $tp_value->children : array(), isset($tp_value->fresh) ? $tp_value->fresh : false)), true);
                        }
                        $value = $tp_value->evaluate();
                    } else {
                        $value = '';
                    }
                } else {
                    $value = '';
                }
            } else {
                $value = '';
            }
            $LOADED_PANELS[serialize($param)] = $value;
            return;
        case 'JS_TEMPCODE':
            if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                $param = $bit[3];
                foreach ($param as $i => $p) {
                    if (is_object($p)) {
                        $param[$i] = $p->evaluate();
                    }
                }
                $temp = javascript_tempcode(array_key_exists(0, $param) ? $param[0] : NULL);
                $children[] = array(':container', isset($temp->children) ? $temp->children : array(), isset($temp->fresh) ? $temp->fresh : false);
            }
            return;
        case 'CSS_TEMPCODE':
            if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                $param = $bit[3];
                $temp = css_tempcode();
                $children[] = array(':container', isset($temp->children) ? $temp->children : array(), isset($temp->fresh) ? $temp->fresh : false);
            }
            return;
        case 'LOAD_PAGE':
            $param = $bit[3];
            foreach ($param as $i => $p) {
                if (is_object($p)) {
                    $param[$i] = $p->evaluate();
                }
            }
            global $LOADED_PAGES;
            if (array_key_exists(serialize($param), $LOADED_PAGES)) {
                return;
            }
            if (array_key_exists(0, $param)) {
                if (strpos($param[0], ':') !== false) {
                    $param = array_reverse(explode(':', $param[0], 2));
                }
                $being_included = !array_key_exists(2, $param) || $param[2] == '1';
                if (function_exists('memory_get_usage') && isset($_GET['keep_show_loading']) && $_GET['keep_show_loading'] == '1') {
                    $before = memory_get_usage();
                }
                $tp_value = request_page($param[0], false, array_key_exists(1, $param) ? $param[1] : NULL, NULL, $being_included);
                if (function_exists('memory_get_usage') && isset($_GET['keep_show_loading']) && $_GET['keep_show_loading'] == '1') {
                    @ob_end_flush();
                    @ob_end_flush();
                    @ob_end_flush();
                    print '<!-- page: ' . htmlentities($param[0]) . ' (' . clean_file_size(memory_get_usage() - $before) . ' bytes used, now at ' . number_format(memory_get_usage()) . ') -->' . "\n";
                    flush();
                }
                if ($GLOBALS['RECORD_TEMPLATES_TREE']) {
                    $children[] = array(':page: ' . $param[0], isset($tp_value->children) ? $tp_value->children : array(), isset($tp_value->fresh) ? $tp_value->fresh : false);
                }
            } else {
                $tp_value = new ocp_tempcode();
            }
            $LOADED_PAGES[serialize($param)] = $tp_value;
            return;
        case 'FRACTIONAL_EDITABLE':
            require_javascript('javascript_fractional_edit');
            return;
    }
}
コード例 #12
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));
 }
コード例 #13
0
ファイル: tar.php プロジェクト: erico-deh/ocPortal
/**
 * Add a folder to the TAR archive
 *
 * @param  array			The TAR file handle
 * @param  ?resource		The logfile to write to (NULL: no logging)
 * @param  PATH			The full path to the folder to add
 * @param  ?integer		The maximum file size to add (NULL: no limit)
 * @param  PATH			The subpath relative to the path (should be left as the default '', as this is used for the recursion to distinguish the adding base path from where it's currently looking)
 * @param  ?array			A map (filename=>1) of files to not back up (NULL: none)
 * @param  ?array			A list of directories ONLY to back up from the root (NULL: no restriction)
 * @param  boolean		Whether to output spaces as we go to keep the connection alive
 * @param  boolean		Whether to not skip "special files" (ones not normally archive)
 */
function tar_add_folder(&$resource, $logfile, $path, $max_size = NULL, $subpath = '', $avoid_backing_up = NULL, $root_only_dirs = NULL, $tick = false, $all_files = false)
{
    require_code('files');
    $_full = $path == '' ? $subpath : $path . '/' . $subpath;
    if ($_full == '') {
        $_full = '.';
    }
    if (!is_null($logfile)) {
        $dh = @opendir($_full);
        if ($dh === false) {
            if (fwrite($logfile, 'Could not access ' . $_full . ' [case 2]' . "\n") == 0) {
                warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
            }
        }
    } else {
        $dh = opendir($_full);
    }
    if ($dh !== false) {
        while (($entry = readdir($dh)) !== false) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            if ($tick) {
                @(print ' ');
            }
            $_subpath = $subpath == '' ? $entry : $subpath . '/' . $entry;
            if (($all_files || !should_ignore_file($_subpath)) && $entry != 'backups') {
                $full = $path == '' ? $_subpath : $path . '/' . $_subpath;
                if (!is_readable($full)) {
                    if (fwrite($logfile, 'Could not access ' . $full . "\n") == 0) {
                        warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                    }
                    continue;
                }
                if (is_dir($full)) {
                    if (is_null($root_only_dirs) || in_array($entry, $root_only_dirs)) {
                        tar_add_folder($resource, $logfile, $path, $max_size, $_subpath, $avoid_backing_up, NULL, $tick, $all_files);
                    }
                } else {
                    if ($full != $resource['full'] && (is_null($max_size) || filesize($full) < $max_size * 1024 * 1024) && (is_null($avoid_backing_up) || !array_key_exists($_subpath, $avoid_backing_up))) {
                        //echo $_subpath.'<br />';
                        tar_add_file($resource, $_subpath, $full, fileperms($full), filemtime($full), true);
                        if (!is_null($logfile) && fwrite($logfile, 'Backed up file ' . $full . ' (' . clean_file_size(filesize($full)) . ')' . "\n") == 0) {
                            warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                        }
                    }
                }
            }
        }
        closedir($dh);
    }
}
コード例 #14
0
ファイル: cms_cedi.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI for editing a CEDI page.
  *
  * @return tempcode	The UI.
  */
 function edit_page()
 {
     $title = get_page_title('CEDI_EDIT_PAGE');
     $__id = get_param('id', '', true);
     if ($__id == '' || strpos($__id, '/') !== false) {
         $_id = get_param_cedi_chain('id');
         $id = intval($_id[0]);
     } else {
         $id = intval($__id);
     }
     check_edit_permission('cat_low', NULL, array('seedy_page', $id));
     if (!has_category_access(get_member(), 'seedy_page', strval($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $pages = $GLOBALS['SITE_DB']->query_select('seedy_pages', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $pages)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $page = $pages[0];
     $page_title = get_translated_text($page['title']);
     $description = get_translated_text($page['description']);
     $_description = get_translated_tempcode($page['description']);
     $redir_url = get_param('redirect', NULL);
     if (is_null($redir_url)) {
         $_redir_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => get_param('id', false, true) == strval(db_get_first_id()) ? NULL : get_param('id', false, true)), get_module_zone('cedi'));
         $redir_url = $_redir_url->evaluate();
     }
     $edit_url = build_url(array('page' => '_SELF', 'redirect' => $redir_url, 'id' => get_param('id', false, true), 'type' => '_edit_page'), '_SELF');
     list($fields, $fields2, $hidden) = $this->get_page_fields($page_title, $page['notes'], $page['hide_posts'], $id);
     require_code('seo2');
     $fields2->attach(seo_get_fields('seedy_page', strval($id)));
     if (addon_installed('awards')) {
         // Awards?
         require_code('awards');
         $fields2->attach(get_award_fields('seedy_page', strval($id)));
     }
     if (has_delete_permission('cat_low', get_member(), NULL, NULL, array('seedy_page', $id)) && $id != db_get_first_id()) {
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $fields2->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     }
     $restore_from = get_param_integer('restore_from', -1);
     if ($restore_from != -1) {
         $description = $GLOBALS['SITE_DB']->query_value('translate_history', 'text_original', array('id' => $restore_from, 'lang_id' => $page['description']));
         // Double selection to stop hacking
         $_description = NULL;
     }
     $posting_form = get_posting_form(do_lang('SAVE'), $description, $edit_url, new ocp_tempcode(), $fields, do_lang_tempcode('PAGE_TEXT'), '', $fields2, $_description, NULL, NULL, false);
     // Revision history
     $revision_history = new ocp_tempcode();
     $revisions = $GLOBALS['SITE_DB']->query_select('translate_history', array('*'), array('lang_id' => $page['description']), 'ORDER BY action_time DESC');
     $last_description = $description;
     foreach ($revisions as $revision) {
         $time = $revision['action_time'];
         $date = get_timezoned_date($time);
         $editor = $GLOBALS['FORUM_DRIVER']->get_username($revision['action_member']);
         $restore_url = build_url(array('page' => '_SELF', 'type' => 'edit_page', 'id' => get_param('id', false, true), 'restore_from' => $revision['id']), '_SELF');
         $size = strlen($revision['text_original']);
         require_code('diff');
         if (function_exists('diff_simple_2')) {
             $rendered_diff = diff_simple_2($revision['text_original'], $last_description);
             $last_description = $revision['text_original'];
             $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'a46de8a930ecfb814695a50b1c4931ac', 'RENDERED_DIFF' => $rendered_diff, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => '', 'SIZE' => clean_file_size($size))));
         }
     }
     if (!$revision_history->is_empty() && $restore_from == -1) {
         $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '1fc38d9d7ec57af110759352446e533d', 'CONTENT' => $revision_history));
     } elseif (!$revision_history->is_empty()) {
         $revision_history = do_template('REVISION_RESTORE');
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     $tree = cedi_breadcrumbs(get_param('id', false, true), NULL, true, true);
     breadcrumb_add_segment($tree, do_lang_tempcode('CEDI_EDIT_PAGE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:edit_page', do_lang_tempcode('CHOOSE'))));
     return do_template('POSTING_SCREEN', array('_GUID' => 'de53b8902ab1431e0d2d676f7d5471d3', 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'REVISION_HISTORY' => $revision_history, 'POSTING_FORM' => $posting_form, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => paragraph(do_lang_tempcode('CEDI_EDIT_PAGE_TEXT'))));
 }
コード例 #15
0
ファイル: myfiles.php プロジェクト: erico-deh/ocPortal
require_code('files2');
$basedir = get_custom_file_base() . '/uploads/filedump/' . $GLOBALS['FORUM_DRIVER']->get_username(get_member());
$baseurl = get_custom_base_url() . '/uploads/filedump/' . rawurlencode($GLOBALS['FORUM_DRIVER']->get_username(get_member()));
$files = file_exists($basedir) ? get_directory_contents($basedir) : array();
if (count($files) == 0) {
    echo '<p class="nothing_here">No files have been uploaded for you yet.</p>';
} else {
    natsort($files);
    echo '<div class="wide_table_wrap"><table class="wide_table solidborder">';
    echo '<colgroup><col width="25%" /><col width="75%" /><col width="100px" /></colgroup>';
    echo '<thead><tr><th>Filename</th><th>Description</th><th>File size</th></tr></thead>';
    echo '<tbody>';
    foreach ($files as $file) {
        $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => '/' . $GLOBALS['FORUM_DRIVER']->get_username(get_member()) . '/'));
        if (!array_key_exists(0, $dbrows)) {
            $description = do_lang_tempcode('NONE_EM');
        } else {
            $description = make_string_tempcode(get_translated_text($dbrows[0]['description']));
        }
        echo '
			<tr>
				<td><a target="_blank" href="' . escape_html($baseurl . '/' . $file) . '">' . escape_html($file) . '</a></td>
				<td>' . $description->evaluate() . '</td>
				<td>' . escape_html(clean_file_size(filesize($basedir . '/' . $file))) . '</td>
			</tr>
		';
    }
    echo '</tbody>';
    echo '</table></div>';
}
コード例 #16
0
ファイル: downloads.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to view a download.
  *
  * @return tempcode		The UI
  */
 function dloadinfo_screen()
 {
     $id = get_param_integer('id');
     $root = get_param_integer('root', db_get_first_id(), true);
     // Basic Init
     $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('SECTION_DOWNLOADS'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter=' . strval($myrow['category_id']);
     if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) {
         access_denied('CATEGORY_ACCESS');
     }
     $name = get_translated_text($myrow['name']);
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $id), '_SELF', NULL, false, false, true), $name, get_value('comment_forum__downloads'));
     // Views
     if (get_db_type() != 'xml') {
         $myrow['download_views']++;
         $GLOBALS['SITE_DB']->query_update('download_downloads', array('download_views' => $myrow['download_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     // Tree
     $tree = download_breadcrumbs($myrow['category_id'], $root, false, get_zone_name());
     $title_to_use = do_lang_tempcode('DOWNLOAD_TITLE', escape_html($name));
     $title_to_use_2 = do_lang('DOWNLOAD_TITLE', $name);
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('download', strval($id));
     } else {
         $awards = array();
     }
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     seo_meta_load_for('downloads_download', strval($id), $title_to_use_2);
     $warning_details = new ocp_tempcode();
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '5b1781b8fbb1ef9b8f47693afcff02b9', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))));
     }
     // Cost warning
     if ($myrow['download_cost'] != 0 && addon_installed('points')) {
         require_lang('points');
         $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '05fc448bf79b373385723c5af5ec93af', 'WARNING' => do_lang_tempcode('WILL_COST', integer_format($myrow['download_cost'])))));
     }
     // Admin functions
     $edit_url = new ocp_tempcode();
     $add_img_url = new ocp_tempcode();
     if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_downloads', array('downloads', $myrow['category_id']))) {
         $edit_url = build_url(array('page' => 'cms_downloads', 'type' => '_ed', 'id' => $id), get_module_zone('cms_downloads'));
     }
     if (addon_installed('galleries')) {
         if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) {
             require_lang('galleries');
             $add_img_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => 'download_' . strval($id)), get_module_zone('cms_galleries'));
         }
     }
     // Outmoding
     if (!is_null($myrow['out_mode_id'])) {
         $outmode_url = build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $myrow['out_mode_id'], 'root' => $root == db_get_first_id() ? NULL : $root), '_SELF');
     } else {
         $outmode_url = new ocp_tempcode();
     }
     // Stats
     $add_date = get_timezoned_date($myrow['add_date'], false);
     // Additional information
     $additional_details = get_translated_tempcode($myrow['comments']);
     // Edit date
     if (!is_null($myrow['edit_date'])) {
         $edit_date = make_string_tempcode(get_timezoned_date($myrow['edit_date'], false));
     } else {
         $edit_date = new ocp_tempcode();
     }
     $images_details = new ocp_tempcode();
     $image_url = '';
     $counter = 0;
     if (addon_installed('galleries')) {
         // Images
         require_lang('galleries');
         $cat = 'download_' . strval($id);
         $map = array('cat' => $cat);
         if (!has_specific_permission(get_member(), 'see_unvalidated')) {
             $map['validated'] = 1;
         }
         $rows = $GLOBALS['SITE_DB']->query_select('images', array('*'), $map, 'ORDER BY id', 200);
         $div = 2;
         $_out = new ocp_tempcode();
         $_row = new ocp_tempcode();
         require_code('images');
         while (array_key_exists($counter, $rows)) {
             $row = $rows[$counter];
             //		$view_url=build_url(array('page'=>'galleries','type'=>'image','wide'=>1,'id'=>$row['id']),get_module_zone('galleries'));
             $view_url = $row['url'];
             if ($image_url == '') {
                 $image_url = $row['url'];
             }
             if (url_is_local($view_url)) {
                 $view_url = get_custom_base_url() . '/' . $view_url;
             }
             $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', 'images', $row['id']);
             $comment = get_translated_tempcode($row['comments']);
             $thumb = do_image_thumb($thumb_url, '');
             if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $row['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) {
                 $iedit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ed', 'id' => $row['id']), get_module_zone('cms_galleries'));
             } else {
                 $iedit_url = new ocp_tempcode();
             }
             $_content = do_template('DOWNLOAD_SCREEN_IMAGE', array('_GUID' => 'fba0e309aa0ae04891e32c65a625b177', 'ID' => strval($row['id']), 'VIEW_URL' => $view_url, 'EDIT_URL' => $iedit_url, 'THUMB' => $thumb, 'COMMENT' => $comment));
             $_row->attach(do_template('DOWNLOAD_GALLERY_IMAGE_CELL', array('_GUID' => '8400a832dbed64bb63f264eb3a038895', 'CONTENT' => $_content)));
             if ($counter % $div == 1 && $counter != 0) {
                 $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => '205c4f5387e98c534d5be1bdfcccdd7d', 'CELLS' => $_row)));
                 $_row = new ocp_tempcode();
             }
             $counter++;
         }
         if (!$_row->is_empty()) {
             $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => 'e9667ca2545ac72f85a873f236cbbd6f', 'CELLS' => $_row)));
         }
         $images_details = $_out;
     }
     // Download link
     $author = $myrow['author'];
     $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')) : new ocp_tempcode();
     // Licence
     $licence_title = NULL;
     $licence_url = NULL;
     $licence_hyperlink = NULL;
     $licence = $myrow['download_licence'];
     if (!is_null($licence)) {
         $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence));
         if (!is_null($licence_title)) {
             $keep = symbol_tempcode('KEEP');
             $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate();
             $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license'));
         } else {
             $licence = NULL;
             // Orphaned
         }
     }
     breadcrumb_add_segment($tree, $title_to_use);
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Download', 'title' => get_translated_text($myrow['name']), 'identifier' => '_SEARCH:downloads:view:' . strval($id), 'description' => get_translated_text($myrow['description']), 'image' => $image_url);
     return do_template('DOWNLOAD_SCREEN', array('_GUID' => 'a9af438f84783d0d38c20b5f9a62dbdb', 'ORIGINAL_FILENAME' => $myrow['original_filename'], 'URL' => $myrow['url'], 'NUM_IMAGES' => strval($counter), 'TAGS' => get_loaded_tags('downloads'), 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink, 'SUBMITTER' => strval($myrow['submitter']), 'EDIT_DATE' => $edit_date, 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'VIEWS' => integer_format($myrow['download_views']), 'NAME' => $name, 'DATE' => $add_date, 'DATE_RAW' => strval($myrow['add_date']), 'NUM_DOWNLOADS' => integer_format($myrow['num_downloads']), 'TITLE' => $title, 'OUTMODE_URL' => $outmode_url, 'WARNING_DETAILS' => $warning_details, 'EDIT_URL' => $edit_url, 'ADD_IMG_URL' => $add_img_url, 'DESCRIPTION' => get_translated_tempcode($myrow['description']), 'ADDITIONAL_DETAILS' => $additional_details, 'IMAGES_DETAILS' => $images_details, 'ID' => strval($id), 'FILE_SIZE' => clean_file_size($myrow['file_size']), 'AUTHOR_URL' => $author_url, 'AUTHOR' => $author, 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENTS_DETAILS' => $comment_details));
 }
コード例 #17
0
ファイル: downloads.php プロジェクト: erico-deh/ocPortal
/**
 * Get tempcode for a download 'feature box' for the sgiven row
 *
 * @param  array			The database field row of this download
 * @param  boolean		Whether to show a picture
 * @param  boolean		Whether to show breadcrumbs
 * @param  ?ID_TEXT		The zone the download module we're using is in (NULL: find it)
 * @param  ?string		Text summary for result (e.g. highlighted portion of actual file from search result) (NULL: none)
 * @return tempcode		A box for this download, linking to the full download page
 */
function get_download_html($row, $pic = true, $breadcrumbs = true, $zone = NULL, $text_summary = NULL)
{
    require_css('downloads');
    if (is_null($zone)) {
        $zone = get_module_zone('downloads');
    }
    // Details
    $filesize = $row['file_size'];
    $filesize = $filesize > 0 ? clean_file_size($filesize) : do_lang('UNKNOWN');
    $description = get_translated_tempcode($row['description']);
    $root = get_param_integer('root', db_get_first_id(), true);
    $download_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $row['id'], 'root' => $root == db_get_first_id() ? NULL : $root), $zone);
    $date = get_timezoned_date($row['add_date'], false);
    $date_raw = $row['add_date'];
    $tree = get_option('show_dload_trees') == '1' && $breadcrumbs ? download_breadcrumbs($row['category_id'], NULL, false, $zone) : new ocp_tempcode();
    $pic_suffix = '';
    $thumb_url = '';
    $full_img_url = '';
    if (addon_installed('galleries') && $pic) {
        // Images
        $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url', 'id'), array('cat' => 'download_' . strval($row['id'])), '', 1, $row['default_pic'] - 1);
        if (array_key_exists(0, $rows)) {
            $pic_suffix = '_pic';
            require_code('images');
            $full_img_url = $rows[0]['url'];
            $thumb_url = ensure_thumbnail($rows[0]['url'], $rows[0]['thumb_url'], 'galleries', 'images', $rows[0]['id']);
            $imgcode = do_image_thumb($thumb_url, do_lang('DOWNLOAD_THUMBNAIL'));
        } else {
            $imgcode = new ocp_tempcode();
        }
    } else {
        $imgcode = new ocp_tempcode();
    }
    require_code('feedback');
    $rating = $row['allow_rating'] == 1 ? display_rating($download_url, get_translated_text($row['name']), 'downloads', strval($row['id']), 'RATING_INLINE_STATIC', $row['submitter']) : NULL;
    if (!is_null($rating)) {
        if (trim($rating->evaluate()) == '') {
            $rating = NULL;
        }
    }
    $licence_title = NULL;
    $licence_url = NULL;
    $licence_hyperlink = NULL;
    $licence = $row['download_licence'];
    if (!is_null($licence)) {
        $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence));
        if (!is_null($licence_title)) {
            $keep = symbol_tempcode('KEEP');
            $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate();
            $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license'));
        } else {
            $licence = NULL;
            // Orphaned
        }
    }
    // Final template
    if ($full_img_url != '' && url_is_local($full_img_url)) {
        $full_img_url = get_custom_base_url() . '/' . $full_img_url;
    }
    return do_template('DOWNLOAD_BOX', array('TEXT_SUMMARY' => $text_summary, 'AUTHOR' => $row['author'], 'ID' => strval($row['id']), 'RATING' => $rating, 'VIEWS' => integer_format($row['download_views']), 'SUBMITTER' => strval($row['submitter']), 'DESCRIPTION' => $description, 'FILE_SIZE' => $filesize, 'DOWNLOADS' => integer_format($row['num_downloads']), 'DATE_RAW' => strval($date_raw), 'DATE' => $date, 'EDIT_DATE_RAW' => is_null($row['edit_date']) ? '' : strval($row['edit_date']), 'SIZE' => $filesize, 'URL' => $download_url, 'NAME' => get_translated_text($row['name']), 'TREE' => $tree, 'IMG_URL' => $thumb_url, 'FULL_IMG_URL' => $full_img_url, 'IMGCODE' => $imgcode, 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink));
}
コード例 #18
0
ファイル: failure.php プロジェクト: erico-deh/ocPortal
/**
 * Complain about a POST field being missing.
 *
 * @param  string			The name of the parameter
 */
function improperly_filled_in_post($name)
{
    $GLOBALS['HTTP_STATUS_CODE'] = '400';
    if (!headers_sent()) {
        if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
            header('HTTP/1.0 400 Bad Request');
        }
    }
    if (count($_POST) == 0 && get_option('user_postsize_errors') == '1') {
        $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize')));
        $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size')));
        warn_exit(do_lang_tempcode(get_param_integer('uploading', 0) == 1 ? 'SHOULD_HAVE_BEEN_POSTED_FILE_ERROR' : 'SHOULD_HAVE_BEEN_POSTED', escape_html($name), escape_html($post_max_size), escape_html($upload_max_filesize)));
    }
    // We didn't give some required input
    warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
}
コード例 #19
0
ファイル: lorem.php プロジェクト: erico-deh/ocPortal
/**
 * Get suitable placeholder filesize.
 *
 * @return string			Place holder text.
 */
function placeholder_filesize()
{
    require_code('files2');
    return clean_file_size(123);
}
コード例 #20
0
ファイル: admin.php プロジェクト: erico-deh/ocPortal
 /**
  * Actualiser to perform Admin Zone search.
  *
  * @return tempcode	Interface.
  */
 function search()
 {
     require_all_lang();
     require_code('zones2');
     disable_php_memory_limit();
     if (function_exists('set_time_limit')) {
         @set_time_limit(100);
     }
     $n = mixed();
     $default_theme = $GLOBALS['FORUM_DRIVER']->get_theme('');
     // Mess around to find our search keywords (takes synonyms into account, and generally tidies up)
     $raw_search_string = get_param('search_content', false, true);
     // Work out our keywords
     $keyword_string = $raw_search_string;
     $_keywords = array();
     $current_word = '';
     $in_quotes = false;
     for ($xi = 0; $xi < strlen($keyword_string); $xi++) {
         if ($in_quotes || trim($keyword_string[$xi]) != '') {
             if ($keyword_string[$xi] == '"') {
                 $in_quotes = !$in_quotes;
             } else {
                 $current_word .= $keyword_string[$xi];
             }
         } else {
             if ($current_word != '') {
                 $_keywords[] = $current_word;
             }
             $current_word = '';
         }
     }
     if ($current_word != '') {
         $_keywords[] = $current_word;
     }
     $_keywords = $this->_strip_junk_words($_keywords);
     if (count($_keywords) == 0) {
         return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => get_page_title('ADMIN_ZONE_SEARCH_RESULTS'), 'EMPTY' => true, 'ARRAY' => true, 'CONTENT' => '', 'PRE' => '', 'POST' => ''));
     }
     $keywords = array();
     $synonym_rows = $this->_synonyms();
     // Only in English by default. To do for another language, override this file using inheritance
     $section_limitations = array();
     foreach ($_keywords as $xi => $keyword) {
         $_keywords = array();
         $keyword = trim($keyword);
         if ($keyword == '') {
             continue;
         }
         if (substr($keyword, 0, 1) == '@') {
             $section_limitations[] = substr($keyword, 1);
             continue;
         }
         foreach ($synonym_rows as $synonyms) {
             if (in_array(strtolower($keyword), $synonyms) || array_key_exists($xi + 1, $_keywords) && in_array(strtolower($_keywords[$xi] . ' ' . $_keywords[$xi + 1]), $synonyms)) {
                 $_keywords = array_merge($_keywords, $synonyms);
             }
         }
         $_keywords[] = $keyword;
         $keywords[] = $_keywords;
     }
     // Stemming, if available (needs Stemmer class like http://www.chuggnutt.com/stemmer-source.php which we can't redistribute due to it being GPL not LGPL)
     if (file_exists(get_file_base() . '/sources_custom/stemmer_' . user_lang() . '.php') && !in_safe_mode()) {
         require_code('stemmer_' . user_lang());
         $stemmer = object_factory('Stemmer_' . user_lang());
         foreach ($keywords as $i => $keyword_group) {
             $_keyword_group = $keyword_group;
             foreach ($keyword_group as $keyword) {
                 // Special stemmer exceptions
                 if ($keyword == 'news') {
                     continue;
                 }
                 if ($keyword == 'defaultness') {
                     continue;
                 }
                 $_keyword_group[] = $stemmer->stem($keyword);
             }
             $keywords[$i] = array_unique($_keyword_group);
         }
     } else {
         foreach ($keywords as $i => $keyword_group) {
             $_keyword_group = $keyword_group;
             foreach ($keyword_group as $keyword) {
                 if (strlen($keyword) > 3 && substr($keyword, -1) == 's') {
                     $_keyword_group[] = substr($keyword, 0, strlen($keyword) - 1);
                 } else {
                     $_keyword_group[] = $keyword . 's';
                 }
             }
             $keywords[$i] = array_unique($_keyword_group);
         }
     }
     $this->keywords = $keywords;
     $content = array();
     // Admin/CMS menu icons
     $current_results_type = do_lang('ADMIN_MODULES');
     if ($this->_section_match($section_limitations, $current_results_type)) {
         $content[$current_results_type] = new ocp_tempcode();
         $hooks = find_all_hooks('systems', 'do_next_menus');
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $info = $object->run(true);
             foreach ($info as $i) {
                 if (is_null($i)) {
                     continue;
                 }
                 $n = $i[3];
                 if ($i[0] != '' && $this->_keyword_match(is_object($n) ? $n->evaluate() : $n) && has_actual_page_access(get_member(), $i[2][0], $i[2][2])) {
                     $_url = build_url(array('page' => $i[2][0]) + $i[2][1], $i[2][2]);
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => $i[0]), 'adminzone'), do_lang(strtoupper($i[0]))));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                 }
             }
         }
     }
     // Module entry points
     $current_results_type = do_lang('SCREENS');
     if ($this->_section_match($section_limitations, $current_results_type)) {
         $content[$current_results_type] = new ocp_tempcode();
         foreach (find_all_zones(false, true) as $zone => $zone_details) {
             $modules = find_all_modules($zone);
             foreach (array_keys($modules) as $page) {
                 $_entrypoints = extract_module_functions_page($zone, $page, array('get_entry_points'));
                 if (!is_null($_entrypoints[0])) {
                     if (is_array($_entrypoints[0]) || strpos($_entrypoints[0], '::') === false) {
                         $entry_points = is_array($_entrypoints[0]) ? call_user_func_array($_entrypoints[0][0], $_entrypoints[0][1]) : eval($_entrypoints[0]);
                     } else {
                         $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone == '' ? '' : '/') . 'pages/modules_custom/' . filter_naughty($page) . '.php', true);
                         if (!file_exists(get_file_base() . '/' . $path)) {
                             $path = zone_black_magic_filterer(filter_naughty($zone) . '/pages/modules/' . filter_naughty($page) . '.php', true);
                         }
                         if (!defined('HIPHOP_PHP') && (ini_get('memory_limit') != '-1' && ini_get('memory_limit') != '0' || get_option('has_low_memory_limit') === '1') && strpos(file_get_contents(get_file_base() . '/' . $path), ' extends standard_aed_module') !== false) {
                             $new_code = str_replace(',parent::get_entry_points()', '', str_replace('parent::get_entry_points(),', '', $_entrypoints[0]));
                             if (strpos($new_code, 'parent::') !== false) {
                                 continue;
                             }
                             $entry_points = eval($new_code);
                         } else {
                             require_code($path);
                             if (class_exists('Mx_' . filter_naughty_harsh($page))) {
                                 $object = object_factory('Mx_' . filter_naughty_harsh($page));
                             } else {
                                 $object = object_factory('Module_' . filter_naughty_harsh($page));
                             }
                             $entry_points = $object->get_entry_points();
                         }
                     }
                     if ($page == 'admin_themes') {
                         $entry_points['!themes'] = 'EDIT_CSS';
                         $entry_points['!!themes'] = 'EDIT_TEMPLATES';
                         $entry_points['!!!themes'] = 'MANAGE_THEME_IMAGES';
                     }
                     if (is_null($entry_points)) {
                         $entry_points = array();
                     }
                     foreach ($entry_points as $type => $lang) {
                         $type = str_replace('!', '', $type);
                         // The ! was a hackerish thing just to multiply-up possibilities for the single entry-point
                         $n = do_lang_tempcode($lang);
                         if ($this->_keyword_match($n->evaluate()) && has_actual_page_access(get_member(), $page, $zone)) {
                             $tree = new ocp_tempcode();
                             $tree->attach(hyperlink(build_url(array('page' => ''), $zone), $zone_details[1]));
                             if ($zone == 'cms' || $zone == 'adminzone') {
                                 if ($page != 'admin' && $page != 'cms') {
                                     $hooks = find_all_hooks('systems', 'do_next_menus');
                                     foreach (array_keys($hooks) as $hook) {
                                         require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook));
                                         $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true);
                                         if (is_null($object)) {
                                             continue;
                                         }
                                         $info = $object->run();
                                         foreach ($info as $i) {
                                             if (is_null($i)) {
                                                 continue;
                                             }
                                             if ($page == $i[2][0] && (!array_key_exists('type', $i[2][1]) && $type == 'misc' || array_key_exists('type', $i[2][1]) && $type == $i[2][1]['type']) && $zone == $i[2][2]) {
                                                 if ($i[0] == 'cms') {
                                                     $_url = build_url(array('page' => 'cms', 'type' => $i[0]), 'cms');
                                                 } else {
                                                     $_url = build_url(array('page' => 'admin', 'type' => $i[0]), 'adminzone');
                                                 }
                                                 require_lang('menus');
                                                 require_lang('security');
                                                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                                                 $tree->attach(hyperlink($_url, do_lang_tempcode(strtoupper($i[0]))));
                                                 if ($type != 'misc') {
                                                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                                                     $tree->attach(hyperlink(build_url(array('page' => $page, 'type' => 'misc'), $zone), $i[3]));
                                                 }
                                                 break 2;
                                             }
                                         }
                                     }
                                 } else {
                                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                                     $tree->attach(hyperlink(build_url(array('page' => $page), $zone), $page));
                                 }
                             }
                             $_url = build_url(array('page' => $page, 'type' => $type), $zone);
                             $sup = $tree->is_empty() ? NULL : do_lang_tempcode('LOCATED_IN', $tree);
                             $site_tree_editor_url = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree', 'id' => $zone . ':' . $page), 'adminzone');
                             $permission_tree_editor_url = build_url(array('page' => 'admin_permissions', 'id' => $zone . ':' . $page), 'adminzone');
                             $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => do_lang_tempcode('FIND_IN_SITE_TREE_EDITOR', escape_html($site_tree_editor_url->evaluate()), escape_html($permission_tree_editor_url->evaluate())), 'SUP' => $sup)));
                         }
                     }
                 }
             }
         }
     }
     $current_results_type = do_lang('IMPORT');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_import')) {
         // Importers
         $content[$current_results_type] = new ocp_tempcode();
         $hooks = find_all_hooks('modules', 'admin_import');
         foreach (array_keys($hooks) as $hook) {
             if ($this->_keyword_match($hook)) {
                 require_code('hooks/modules/admin_import/' . filter_naughty_harsh($hook));
                 $_hook = object_factory('Hook_' . filter_naughty_harsh($hook));
                 $info = $_hook->info();
                 $name = $info['product'];
                 $_url = build_url(array('page' => 'admin_import', 'type' => 'session', 'importer' => $hook), get_module_zone('admin_import'));
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $name, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => '')));
             }
         }
     }
     $current_results_type = do_lang('CONFIGURATION');
     if (($this->_section_match($section_limitations, $current_results_type) || $this->_section_match($section_limitations, do_lang('OPTION_CATEGORIES')) || $this->_section_match($section_limitations, do_lang('OPTION_GROUPS'))) && has_actual_page_access(get_member(), 'admin_config')) {
         // Config options- names, descriptions, groups, categories
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         if (!is_null($GLOBALS['CURRENT_SHARE_USER'])) {
             $map['shared_hosting_restricted'] = 0;
         }
         $all_options = $GLOBALS['SITE_DB']->query_select('config', array('the_name', 'human_name', 'the_page', 'section', 'explanation', 'eval'), $map);
         $all_options[] = array('the_name' => 'timezone', 'human_name' => 'TIME_ZONE', 'config_value' => '', 'the_type' => 'special', 'eval' => '', 'the_page' => 'SITE', 'section' => 'GENERAL', 'explanation' => '', 'shared_hosting_restricted' => 0);
         $config_categories = array();
         $conf_found_count = 0;
         foreach ($all_options as $p) {
             if (defined('HIPHOP_PHP')) {
                 require_code('hooks/systems/config_default/' . $p['the_name']);
                 $hook = object_factory('Hook_config_default_' . $p['the_name']);
                 $null_test = $hook->get_default();
             } else {
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 10;
                 // LEGACY Workaround for corrupt webhost installers
                 $null_test = eval($p['eval']);
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 0;
                 // LEGACY
             }
             if (!is_null($null_test)) {
                 $n = do_lang_tempcode($p['human_name']);
                 switch ($p['the_name']) {
                     case 'timezone':
                         $t = do_lang('DESCRIPTION_TIMEZONE_SITE');
                         break;
                     default:
                         $t = do_lang($p['explanation'], NULL, NULL, NULL, NULL, false);
                         break;
                 }
                 if (is_null($n)) {
                     continue;
                 }
                 $config_value = array_key_exists('config_value', $p) ? $p['config_value'] : get_option($p['the_name']);
                 if ($config_value === false) {
                     continue;
                 }
                 if ($this->_keyword_match($p['the_name']) || $this->_keyword_match($n->evaluate()) || $this->_keyword_match($t) || $this->_keyword_match($config_value)) {
                     $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p['the_page']), 'adminzone');
                     $url = $_url->evaluate();
                     $url .= '#group_' . $p['section'];
                     if (is_null($t)) {
                         $t = '';
                     }
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p['the_page']), 'adminzone'), do_lang('CONFIG_CATEGORY_' . $p['the_page'])));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink($url, do_lang($p['section'])));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => protect_from_escaping($t), 'SUP' => $sup)));
                     if ($conf_found_count > 100) {
                         $content[$current_results_type] = do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'), 'URL' => '', 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => ''));
                         break;
                     }
                     $conf_found_count++;
                     if (!array_key_exists($p['the_page'], $config_categories)) {
                         $config_categories[$p['the_page']] = array();
                     }
                     $config_categories[$p['the_page']][$p['section']] = 1;
                 }
             }
         }
         $current_results_type = do_lang('OPTION_CATEGORIES');
         $content[$current_results_type] = new ocp_tempcode();
         $current_results_type_2 = do_lang('OPTION_GROUPS');
         $content[$current_results_type_2] = new ocp_tempcode();
         foreach ($config_categories as $p => $groups) {
             $_n = do_lang('CONFIG_CATEGORY_' . $p, NULL, NULL, NULL, NULL, false);
             if (is_null($_n)) {
                 continue;
             }
             $n = do_lang_tempcode('CONFIG_CATEGORY_' . $p);
             if ($this->_keyword_match($n->evaluate())) {
                 $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone');
                 $description = do_lang_tempcode('CONFIG_CATEGORY_DESCRIPTION__' . $p);
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $description, 'SUP' => $sup)));
             }
             foreach (array_keys($groups) as $group) {
                 $n2 = do_lang($group, NULL, NULL, NULL, NULL, false);
                 if (is_null($n2)) {
                     continue;
                 }
                 if ($this->_keyword_match($n2)) {
                     $upload_max_filesize = ini_get('upload_max_filesize') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('upload_max_filesize')));
                     $post_max_size = ini_get('post_max_size') == '0' ? do_lang('NA') : clean_file_size(php_return_bytes(ini_get('post_max_size')));
                     $_group_description = do_lang('CONFIG_GROUP_DESCRIP_' . $group, escape_html($post_max_size), escape_html($upload_max_filesize), NULL, NULL, false);
                     if (is_null($_group_description)) {
                         $group_description = new ocp_tempcode();
                     } else {
                         $group_description = do_lang_tempcode('CONFIG_GROUP_DESCRIP_' . $group, escape_html($post_max_size), escape_html($upload_max_filesize), false);
                     }
                     $_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone');
                     $url = $_url->evaluate();
                     $url .= '#group_' . $group;
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('SETUP')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('CONFIGURATION')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $p), 'adminzone'), do_lang('CONFIG_CATEGORY_' . $p)));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type_2]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n2, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $group_description, 'SUP' => $sup)));
                 }
             }
         }
     }
     $current_results_type = do_lang('USERGROUPS');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_ocf_groups') && get_forum_type() == 'ocf') {
         // Usergroups
         $content[$current_results_type] = new ocp_tempcode();
         $map = array('g_is_private_club' => 0);
         $all_groups = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), $map);
         foreach ($all_groups as $p) {
             $n = get_translated_text($p['g_name']);
             if ($this->_keyword_match($n)) {
                 $_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $p['id']), 'adminzone');
                 $url = $_url->evaluate();
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('USERGROUPS')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'ed'), 'adminzone'), do_lang_tempcode('EDIT_GROUP')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
             }
         }
     }
     $current_results_type = do_lang('THEMES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes')) {
         // Themes
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         foreach (array(do_lang('SUPPORTS_WIDE'), do_lang('MOBILE_PAGES')) as $n) {
             if ($this->_keyword_match($n)) {
                 $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_theme', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme('')), 'adminzone');
                 $url = $_url->evaluate();
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                 break;
             }
         }
     }
     $current_results_type = do_lang('ZONES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_zones')) {
         // Zones
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         $all_groups = $GLOBALS['SITE_DB']->query_select('zones', array('zone_name', 'zone_title', 'zone_header_text'), $map, 'ORDER BY zone_title', 50);
         foreach ($all_groups as $p) {
             $n = $p['zone_name'];
             $t = get_translated_text($p['zone_title']);
             $ht = get_translated_text($p['zone_header_text']);
             if ($this->_keyword_match($n) || $this->_keyword_match($t) || $this->_keyword_match($ht)) {
                 $_url = build_url(array('page' => 'admin_zones', 'type' => '_edit', 'id' => $p['zone_name']), 'adminzone');
                 $url = $_url->evaluate();
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'setup'), 'adminzone'), do_lang_tempcode('STRUCTURE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('ZONES')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'edit'), 'adminzone'), do_lang_tempcode('EDIT_ZONE')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($t), 'SUP' => $sup)));
             }
         }
     }
     // Blocks
     $current_results_type = do_lang('_BLOCKS');
     if ($this->_section_match($section_limitations, $current_results_type)) {
         $content[$current_results_type] = new ocp_tempcode();
         $map = array();
         require_code('zones2');
         $all_blocks = find_all_blocks();
         foreach (array_keys($all_blocks) as $p) {
             $t = do_lang('BLOCK_' . $p . '_DESCRIPTION');
             if ($this->_keyword_match($p) || $this->_keyword_match($t)) {
                 $url = '';
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $p, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($t))));
             }
         }
     }
     $current_results_type = do_lang('SPECIFIC_PERMISSIONS');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_permissions')) {
         // Privileges- sections/names/descriptions
         $content[$current_results_type] = new ocp_tempcode();
         $all_permissions = $GLOBALS['SITE_DB']->query_select('sp_list', array('the_name', 'p_section'));
         $pt_sections = array();
         foreach ($all_permissions as $p) {
             $n = do_lang('PT_' . $p['the_name'], NULL, NULL, NULL, NULL, false);
             if (is_null($n)) {
                 continue;
             }
             if ($this->_keyword_match($n) || $this->_keyword_match($p['the_name'])) {
                 $_url = build_url(array('page' => 'admin_permissions', 'type' => 'specific', 'id' => $p['p_section']), 'adminzone');
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_permissions', 'type' => 'specific'), 'adminzone'), do_lang_tempcode('SPECIFIC_PERMISSIONS')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink($_url, do_lang($p['p_section'])));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
             }
             $pt_sections[$p['p_section']] = 1;
         }
         $current_results_type = do_lang('SPECIFIC_PERMISSION_SECTIONS');
         $content[$current_results_type] = new ocp_tempcode();
         foreach (array_keys($pt_sections) as $p) {
             $n = do_lang($p, NULL, NULL, NULL, NULL, false);
             if (is_null($n)) {
                 continue;
             }
             if ($this->_keyword_match($n) || $this->_keyword_match($p)) {
                 $_url = build_url(array('page' => 'admin_permissions', 'type' => 'specific', 'id' => $p), 'adminzone');
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_permissions', 'type' => 'specific'), 'adminzone'), do_lang_tempcode('SPECIFIC_PERMISSIONS')));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
             }
         }
     }
     $current_results_type = do_lang('USERGROUP_SETTINGS');
     if ($this->_section_match($section_limitations, $current_results_type) && get_forum_type() == 'ocf' && has_actual_page_access(get_member(), 'admin_ocf_groups', 'adminzone')) {
         // Usergroup settings
         $content[$current_results_type] = new ocp_tempcode();
         $applicable_langstrings = array(array('ENQUIRE_ON_NEW_IPS', 'DESCRIPTION_ENQUIRE_ON_NEW_IPS'), array('FLOOD_CONTROL_ACCESS_SECS', 'DESCRIPTION_FLOOD_CONTROL_ACCESS_SECS'), array('FLOOD_CONTROL_SUBMIT_SECS', 'DESCRIPTION_FLOOD_CONTROL_SUBMIT_SECS'), array('MAX_ATTACHMENTS_PER_POST', 'DESCRIPTION_MAX_ATTACHMENTS_PER_POST'), array('MAX_DAILY_UPLOAD_MB', 'DESCRIPTION_MAX_DAILY_UPLOAD_MB'), array('MAX_AVATAR_WIDTH', 'DESCRIPTION_MAX_AVATAR_WIDTH'), array('MAX_AVATAR_HEIGHT', 'DESCRIPTION_MAX_AVATAR_HEIGHT'), array('MAX_POST_LENGTH_COMCODE', 'DESCRIPTION_MAX_POST_LENGTH_COMCODE'), array('MAX_SIG_LENGTH_COMCODE', 'DESCRIPTION_MAX_SIG_LENGTH_COMCODE'));
         if (addon_installed('points')) {
             $applicable_langstrings = array_merge($applicable_langstrings, array(array('GIFT_POINTS_BASE', 'DESCRIPTION_GIFT_POINTS_BASE'), array('GIFT_POINTS_PER_DAY', 'DESCRIPTION_GIFT_POINTS_PER_DAY')));
         }
         foreach ($applicable_langstrings as $_langstring) {
             $array = is_array($_langstring) ? $_langstring : array($_langstring);
             foreach ($array as $langstring) {
                 $n = do_lang($langstring);
                 if ($this->_keyword_match($n)) {
                     $n = do_lang_tempcode($array[0]);
                     $_url = build_url(array('page' => 'admin_ocf_groups', 'type' => 'ed'), 'adminzone');
                     $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode();
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'security'), 'adminzone'), do_lang_tempcode('SECURITY')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_ocf_groups', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('USERGROUPS')));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $descrip, 'SUP' => $sup)));
                     continue 2;
                 }
             }
         }
     }
     $current_results_type = do_lang('MEMBER_SETTINGS');
     if ($this->_section_match($section_limitations, $current_results_type) && get_forum_type() == 'ocf' && has_actual_page_access(get_member(), 'members')) {
         // Member settings
         $content[$current_results_type] = new ocp_tempcode();
         $applicable_langstrings = array(array('WIDE', 'DESCRIPTION_WIDE'), array('REVEAL_AGE', 'DESCRIPTION_REVEAL_AGE'), array('PREVIEW_POSTS', 'DESCRIPTION_PREVIEW_POSTS'), array('AUTO_NOTIFICATION_CONTRIB_CONTENT', 'DESCRIPTION_AUTO_NOTIFICATION_CONTRIB_CONTENT'), array('PT_RULES_TEXT', 'PT_RULES_TEXT_DESCRIPTION'));
         foreach ($applicable_langstrings as $_langstring) {
             $array = is_array($_langstring) ? $_langstring : array($_langstring);
             foreach ($array as $langstring) {
                 $n = do_lang($langstring);
                 if ($this->_keyword_match($n)) {
                     $n = do_lang_tempcode($array[0]);
                     $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode();
                     $_url = build_url(array('page' => 'members', 'type' => 'view'), get_module_zone('members'), NULL, false, false, false, 'tab__edit');
                     $url = $_url->evaluate();
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $descrip)));
                     continue 2;
                 }
             }
         }
     }
     // Zone options
     $current_results_type = do_lang('ZONE_OPTIONS');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_zones', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $applicable_langstrings = array(array('DEFAULT_PAGE', 'DESCRIPTION_DEFAULT_PAGE'), array('HEADER_TEXT', 'DESCRIPTION_HEADER_TEXT'), array('WIDE', 'DESCRIPTION_WIDE'), array('REQUIRE_SESSION', 'DESCRIPTION_REQUIRE_SESSION'), array('DISPLAYED_IN_MENU', 'DESCRIPTION_DISPLAYED_IN_MENU'), array('THEME', get_forum_type() == 'ocf' ? '_DESCRIPTION_THEME_OCF' : '_DESCRIPTION_THEME'));
         foreach ($applicable_langstrings as $_langstring) {
             $array = is_array($_langstring) ? $_langstring : array($_langstring);
             foreach ($array as $langstring) {
                 $n = do_lang($langstring);
                 if ($this->_keyword_match($n)) {
                     $n = do_lang_tempcode($array[0]);
                     $_url = build_url(array('page' => 'admin_zones', 'type' => 'edit'), 'adminzone');
                     $descrip = array_key_exists(1, $array) ? do_lang_tempcode($array[1]) : new ocp_tempcode();
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'structure'), 'adminzone'), do_lang_tempcode('STRUCTURE')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_zones', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('ZONES')));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $descrip, 'SUP' => $sup)));
                     continue 2;
                 }
             }
         }
     }
     // Install options
     $current_results_type = do_lang('BASE_CONFIGURATION');
     if ($this->_section_match($section_limitations, $current_results_type) && $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
         $content[$current_results_type] = new ocp_tempcode();
         if (file_exists(get_file_base() . '/config_editor.php')) {
             $file_contents = file_get_contents(get_file_base() . '/config_editor.php');
             $matches = array();
             $num_matches = preg_match_all('#case \'([^\']+)\':\\n\\s*\\$notes=\'([^\']+)\';#', $file_contents, $matches);
             for ($i = 0; $i < $num_matches; $i++) {
                 $n = stripslashes($matches[2][$i]);
                 if ($this->_keyword_match($n)) {
                     $url = get_base_url() . '/config_editor.php';
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => stripslashes($matches[1][$i]), 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => $n)));
                 }
             }
         }
     }
     // Language string names and contents
     $current_results_type = do_lang('MODULE_TRANS_NAME_admin_lang');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_lang', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         if (user_lang() != fallback_lang()) {
             $content[$current_results_type]->attach(paragraph(do_lang_tempcode('SEARCH_LAUNCHPAD', escape_html(urlencode($raw_search_string)), escape_html(urlencode(user_lang())))));
         }
         global $LANGUAGE;
         $lang_file_contents = array();
         $lang_found = array();
         foreach ($LANGUAGE[user_lang()] as $n => $n_value) {
             if ($this->_keyword_match($n) || $this->_keyword_match($n_value)) {
                 $lang_found[$n] = $n_value;
                 if (count($lang_found) > 100) {
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'), 'URL' => '', 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => '')));
                     $lang_found = array();
                     break;
                 }
             }
         }
         foreach ($lang_found as $n => $n_value) {
             // Try and find what lang file it came from
             $lang_file = 'global';
             foreach (array('lang', 'lang_custom') as $lang_dir) {
                 $dh = @opendir(get_file_base() . '/' . $lang_dir . '/' . fallback_lang() . '/');
                 if ($dh !== false) {
                     while (($file = readdir($dh)) !== false) {
                         if (substr(strtolower($file), -4) == '.ini') {
                             if (!array_key_exists($file, $lang_file_contents)) {
                                 $lang_file_contents[$file] = file_get_contents(get_file_base() . '/' . $lang_dir . '/' . fallback_lang() . '/' . $file);
                             }
                             if (preg_match('#^' . str_replace('#', '\\#', preg_quote($n)) . '=#m', $lang_file_contents[$file]) != 0 || file_exists(get_custom_file_base() . '/lang_custom/' . user_lang() . '/' . $file) && preg_match('#^' . str_replace('#', '\\#', preg_quote($n)) . '=#m', file_get_contents(get_custom_file_base() . '/lang_custom/' . user_lang() . '/' . $file)) != 0) {
                                 $lang_file = basename($file, '.ini');
                                 break;
                             }
                         }
                     }
                 }
             }
             $_url = build_url(array('page' => 'admin_lang', 'type' => 'misc', 'lang' => user_lang(), 'lang_file' => $lang_file), 'adminzone');
             $url = $_url->evaluate();
             $url .= '#jmp_' . $n;
             $tree = new ocp_tempcode();
             $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
             $tree->attach(do_template('BREADCRUMB_ESCAPED'));
             $tree->attach(hyperlink(build_url(array('page' => 'admin_lang', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('TRANSLATE_CONTENT')));
             $tree->attach(do_template('BREADCRUMB_ESCAPED'));
             $tree->attach(hyperlink(build_url(array('page' => 'admin_lang', 'type' => 'misc', 'lang' => user_lang(), 'lang_file' => $lang_file), 'adminzone'), $lang_file));
             $sup = do_lang_tempcode('LOCATED_IN', $tree);
             $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => escape_html($n_value), 'SUP' => $sup)));
         }
         $lang_file_contents = array();
     }
     // Theme images
     $current_results_type = do_lang('MANAGE_THEME_IMAGES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $images = $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'theme', 'lang'));
         foreach ($images as $image) {
             $n = $image['id'];
             if ($this->_keyword_match($n)) {
                 $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_image', 'theme' => $image['theme'], 'lang' => $image['lang'], 'id' => $n), 'adminzone');
                 $tree = new ocp_tempcode();
                 $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $image['theme']), 'adminzone'), do_lang_tempcode('EDIT_THEME_IMAGE')));
                 $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                 $tree->attach(escape_html($image['theme']));
                 $sup = do_lang_tempcode('LOCATED_IN', $tree);
                 $lang = $image['lang'];
                 $lang_map = better_parse_ini_file(file_exists(get_file_base() . '/lang_custom/langs.ini') ? get_file_base() . '/lang_custom/langs.ini' : get_file_base() . '/lang/langs.ini');
                 $lang = array_key_exists($lang, $lang_map) ? $lang_map[$lang] : $lang;
                 $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => $lang, 'SUP' => $sup)));
             }
         }
     }
     // Template names
     $current_results_type = do_lang('TEMPLATES');
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $tpl_found = array();
         foreach (array('templates_custom', 'templates') as $template_dir) {
             $dh = opendir(get_file_base() . '/themes/default/' . $template_dir . '/');
             while (($file = readdir($dh)) !== false) {
                 if (substr(strtolower($file), -4) == '.tpl' && !array_key_exists($file, $tpl_found)) {
                     $n = $file;
                     if ($this->_keyword_match(basename($n, '.tpl')) || $this->_keyword_match($n) || $template_dir == 'templates_custom' && $this->_keyword_match(file_get_contents(get_file_base() . '/themes/default/' . $template_dir . '/' . $n))) {
                         $_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $default_theme, 'f0file' => $file), 'adminzone');
                         $tree = new ocp_tempcode();
                         $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                         $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                         $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'edit_templates', 'theme' => $default_theme), 'adminzone'), do_lang_tempcode('EDIT_TEMPLATES')));
                         $sup = do_lang_tempcode('LOCATED_IN', $tree);
                         $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $_url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                         $tpl_found[$file] = 1;
                     }
                 }
             }
         }
     }
     // CSS file contents
     $current_results_type = 'CSS';
     if ($this->_section_match($section_limitations, $current_results_type) && has_actual_page_access(get_member(), 'admin_themes', 'adminzone')) {
         $content[$current_results_type] = new ocp_tempcode();
         $dh = opendir(get_file_base() . '/themes/default/css/');
         while (($file = readdir($dh)) !== false) {
             if (substr(strtolower($file), -4) == '.css') {
                 $n = $file;
                 if ($this->_keyword_match(file_get_contents(get_file_base() . '/themes/default/css/' . $n))) {
                     $_url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $default_theme, 'file' => $file), 'adminzone');
                     $url = $_url->evaluate();
                     if (isset($keywords[0])) {
                         $url .= '#' . $keywords[0][0];
                     }
                     $tree = new ocp_tempcode();
                     $tree->attach(hyperlink(build_url(array('page' => 'admin', 'type' => 'style'), 'adminzone'), do_lang_tempcode('STYLE')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'misc'), 'adminzone'), do_lang_tempcode('THEMES')));
                     $tree->attach(do_template('BREADCRUMB_ESCAPED'));
                     $tree->attach(hyperlink(build_url(array('page' => 'admin_themes', 'type' => 'choose_css', 'theme' => $default_theme), 'adminzone'), do_lang_tempcode('EDIT_CSS')));
                     $sup = do_lang_tempcode('LOCATED_IN', $tree);
                     $content[$current_results_type]->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('NAME' => $n, 'URL' => $url, 'TITLE' => '', 'DESCRIPTION' => '', 'SUP' => $sup)));
                 }
             }
         }
     }
     //ksort($content);		Don't sort, we have an implicit good order in this code file
     // And show results...
     if (addon_installed('search')) {
         $_search_url = build_url(array('page' => 'search', 'type' => 'results', 'content' => $raw_search_string, 'days' => '-1', 'search_comcode_pages' => 1, 'all_defaults' => 1), get_module_zone('search'));
         $search_url = $_search_url->evaluate();
         $software_search_url = brand_base_url() . '/site/index.php?page=search&type=results&search_under=docs&search_comcode_pages=1&days=-1&content=' . urlencode($raw_search_string);
         $software_search_url_2 = brand_base_url() . '/site/index.php?page=search&type=results&search_ocf_posts=1&days=-1&content=' . urlencode($raw_search_string);
         $pre = do_lang_tempcode('ADMINZONE_SEARCH_RESULTS', escape_html($raw_search_string), escape_html($search_url), array(escape_html($software_search_url), escape_html($software_search_url_2)));
     } else {
         $pre = new ocp_tempcode();
     }
     $found_some = false;
     foreach ($content as $c) {
         if (!$c->is_empty()) {
             $found_some = true;
             break;
         }
     }
     $post = strpos($raw_search_string, '"') !== false || !$found_some ? new ocp_tempcode() : do_lang_tempcode('ADMINZONE_SEARCH_TIP', escape_html(preg_replace('#\\s@\\w+#', '', $raw_search_string)));
     if (!$found_some && $this->and_query) {
         $this->and_query = false;
         return $this->search();
     }
     return do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => get_page_title('ADMIN_ZONE_SEARCH_RESULTS'), 'EMPTY' => $found_some ? NULL : true, 'ARRAY' => true, 'CONTENT' => $content, 'PRE' => $pre, 'POST' => $post));
 }
コード例 #21
0
ファイル: attachments.php プロジェクト: erico-deh/ocPortal
/**
 * Get tempcode for a Comcode rich-media attachment.
 *
 * @param  ID_TEXT		The attachment tag
 * @set attachment attachment_safe attachment2
 * @param  array			A map of the attributes (name=>val) for the tag
 * @param  array			A map of the attachment properties (name=>val) for the attachment
 * @param  string			A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post)
 * @param  MEMBER			The member who is responsible for this Comcode
 * @param  boolean		Whether to check as arbitrary admin
 * @param  object			The database connection to use
 * @param  ?array			A list of words to highlight (NULL: none)
 * @param  ?MEMBER		The member we are running on behalf of, with respect to how attachments are handled; we may use this members attachments that are already within this post, and our new attachments will be handed to this member (NULL: member evaluating)
 * @param  boolean		Whether to parse so as to create something that would fit inside a semihtml tag. It means we generate HTML, with Comcode written into it where the tag could never be reverse-converted (e.g. a block).
 * @return tempcode		The tempcode for the attachment
 */
function render_attachment($tag, $attributes, $attachment, $pass_id, $source_member, $as_admin, $connection, $highlight_bits = NULL, $on_behalf_of_member = NULL, $semiparse_mode = false)
{
    require_code('comcode_renderer');
    $extension = get_file_extension($attachment['a_original_filename']);
    require_code('mime_types');
    $mime_type = get_mime_type($extension);
    $attachment['CLEAN_SIZE'] = clean_file_size($attachment['a_file_size']);
    $attachment['MIME_TYPE'] = $mime_type;
    $attachment['PASS_ID'] = intval($pass_id) < 0 ? strval(mt_rand(0, 10000)) : $pass_id;
    $attachment['SCRIPT'] = find_script('attachment');
    $attachment['RAND'] = strval(mt_rand(0, 32000));
    if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) {
        $attachment['SUP_PARAMS'] = '&forum_db=1';
        $attachment['FORUM_DB_BIN'] = '1';
    } else {
        $attachment['SUP_PARAMS'] = '';
        $attachment['FORUM_DB_BIN'] = '';
    }
    $type = trim(array_key_exists('type', $attributes) ? $attributes['type'] : 'auto');
    $attachment['id'] = strval($attachment['id']);
    $attachment['a_member_id'] = strval($attachment['a_member_id']);
    $attachment['a_file_size'] = strval($attachment['a_file_size']);
    $attachment['a_last_downloaded_time'] = is_null($attachment['a_last_downloaded_time']) ? '' : strval($attachment['a_last_downloaded_time']);
    $attachment['a_add_time'] = strval($attachment['a_add_time']);
    $attachment['a_num_downloads'] = integer_format($attachment['a_num_downloads']);
    require_code('images');
    $attachment['a_width'] = array_key_exists('width', $attributes) ? strval(intval($attributes['width'])) : '';
    $attachment['a_height'] = array_key_exists('height', $attributes) ? strval(intval($attributes['height'])) : '';
    if ($attachment['a_width'] == '' || $attachment['a_height'] == '') {
        if (addon_installed('galleries') && is_video($attachment['a_original_filename']) && url_is_local($attachment['a_url'])) {
            require_code('galleries2');
            $vid_details = get_video_details(get_custom_file_base() . '/' . rawurldecode($attachment['a_url']), $attachment['a_original_filename'], true);
            if ($vid_details !== false) {
                list($_width, $_height, ) = $vid_details;
                if ($attachment['a_width'] == '') {
                    $attachment['a_width'] = strval($_width);
                }
                if ($attachment['a_height'] == '') {
                    $attachment['a_height'] = strval($_height);
                }
            }
        }
        if ($attachment['a_width'] == '' || $attachment['a_height'] == '') {
            if ($attachment['a_width'] == '') {
                $attachment['a_width'] = '240';
            }
            if ($attachment['a_height'] == '') {
                $attachment['a_height'] = '216';
            }
        }
    }
    $attachment['a_align'] = array_key_exists('align', $attributes) ? $attributes['align'] : 'left';
    if (!array_key_exists('a_description', $attachment)) {
        if (array_key_exists('description', $attributes)) {
            $attachment['description'] = $attributes['description'];
        }
        if (!array_key_exists('description', $attachment)) {
            $attachment['description'] = '';
        }
        $attachment['a_description'] = is_object($attachment['description']) ? $attachment['description'] : comcode_to_tempcode($attachment['description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member);
    } else {
        $attachment['a_description'] = comcode_to_tempcode($attachment['a_description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member);
    }
    $attachment['a_type'] = $type;
    $attachment['a_thumb'] = array_key_exists('thumb', $attributes) ? $attributes['thumb'] : '1';
    if ($attachment['a_thumb'] != '0') {
        $attachment['a_thumb'] = '1';
    }
    $attachment['a_thumb_url'] = array_key_exists('thumb_url', $attributes) ? $attributes['thumb_url'] : $attachment['a_thumb_url'];
    switch ($type) {
        case 'email':
            require_code('mail');
            global $EMAIL_ATTACHMENTS;
            if (url_is_local($attachment['a_url'])) {
                $attachment['a_url'] = get_custom_base_url() . '/' . $attachment['a_url'];
            }
            $EMAIL_ATTACHMENTS[$attachment['a_url']] = $attachment['a_original_filename'];
            $temp_tpl = new ocp_tempcode();
            break;
        case 'code':
            $url = $attachment['a_url'];
            if (url_is_local($url)) {
                $url = get_custom_base_url() . '/' . $url;
            }
            $file_contents = http_download_file($url, 1024 * 1024 * 20);
            list($_embed, $title) = do_code_box($extension, make_string_tempcode($file_contents));
            if ($attachment['a_original_filename'] != '') {
                $title = escape_html($attachment['a_original_filename']);
            }
            $temp_tpl = do_template('COMCODE_CODE', array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'STYLE' => '', 'TYPE' => $extension, 'CONTENT' => $_embed, 'TITLE' => $title));
            break;
        case 'hyperlink':
            if ($tag == 'attachment') {
                $keep = symbol_tempcode('KEEP');
                $_url = new ocp_tempcode();
                $_url->attach(find_script('attachment') . '?id=' . urlencode($attachment['id']) . $keep->evaluate());
                if (get_option('anti_leech') == '1') {
                    $_url->attach('&for_session=');
                    $_url->attach(symbol_tempcode('SESSION_HASHED'));
                }
            } else {
                $url = $attachment['a_url'];
                if (url_is_local($url)) {
                    $url = get_custom_base_url() . '/' . $url;
                }
                $_url = make_string_tempcode($url);
            }
            $temp_tpl = hyperlink($_url, is_object($attachment['a_description']) ? $attachment['a_description']->evaluate() : $attachment['a_description'] != '' ? $attachment['a_description'] : $attachment['a_original_filename'], true);
            break;
        default:
            if (is_image($attachment['a_original_filename'])) {
                if ($type == 'inline' || $type == 'left_inline' || $type == 'right_inline') {
                    $attachment['mini'] = '1';
                }
                require_code('images');
                ensure_thumbnail($attachment['a_url'], $attachment['a_thumb_url'], 'attachments', 'attachments', intval($attachment['id']), 'a_thumb_url');
                $temp_tpl = do_template('ATTACHMENT_IMG' . (array_key_exists('mini', $attachment) && $attachment['mini'] == '1' ? '_MINI' : ''), map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                if ($type == 'left' || $type == 'left_inline') {
                    $temp_tpl = do_template('ATTACHMENT_LEFT', array('_GUID' => 'aee2a6842d369c8dae212c3478a3a3e9', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl));
                }
                if ($type == 'right' || $type == 'right_inline') {
                    $temp_tpl = do_template('ATTACHMENT_RIGHT', array('_GUID' => '1a7209d67d91db740c86e7a331720195', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl));
                }
                break;
            } elseif ($extension == 'swf') {
                $temp_tpl = do_template('ATTACHMENT_SWF', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif (addon_installed('jwplayer') && ($mime_type == 'video/x-flv' || $mime_type == 'video/mp4' || $mime_type == 'video/webm')) {
                $temp_tpl = do_template('ATTACHMENT_FLV', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif ($mime_type == 'video/quicktime') {
                $temp_tpl = do_template('ATTACHMENT_QT', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif ($mime_type == 'audio/x-pn-realaudio') {
                $temp_tpl = do_template('ATTACHMENT_RM', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif (substr($mime_type, 0, 5) == 'video' || substr($mime_type, 0, 5) == 'audio') {
                $temp_tpl = do_template('ATTACHMENT_MEDIA', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            }
            // Continues on, as it's not a media type...
        // Continues on, as it's not a media type...
        case 'download':
            if (is_null($attachment['a_file_size'])) {
                $temp_tpl = do_template('ATTACHMENT_DOWNLOAD_REMOTE', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
            } else {
                $temp_tpl = do_template('ATTACHMENT_DOWNLOAD', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
            }
            break;
    }
    return $temp_tpl;
}
コード例 #22
0
ファイル: admin_backup.php プロジェクト: erico-deh/ocPortal
 /**
  * Helper function to find information about past backups.
  *
  * @return tempcode		The UI
  */
 function get_results()
 {
     // Find all files in the incoming directory
     $path = get_custom_file_base() . '/exports/backups/';
     if (!file_exists($path)) {
         mkdir($path, 0777, true);
         fix_permissions($path, 0777);
         sync_file($path);
     }
     $handle = opendir($path);
     $entries = array();
     while (false !== ($file = readdir($handle))) {
         if (!is_dir($path . $file) && (get_file_extension($file) == 'tar' || get_file_extension($file) == 'txt' || get_file_extension($file) == 'gz' || get_file_extension($file) == '') && is_file($path . $file)) {
             $entries[] = array('file' => $file, 'size' => filesize($path . $file), 'mtime' => filemtime($path . $file));
         }
     }
     closedir($handle);
     global $M_SORT_KEY;
     $M_SORT_KEY = 'mtime';
     uasort($entries, 'multi_sort');
     if (count($entries) != 0) {
         require_code('templates_table_table');
         $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('TYPE'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), new ocp_tempcode()));
         $rows = new ocp_tempcode();
         foreach ($entries as $entry) {
             $delete_url = build_url(array('page' => '_SELF', 'type' => 'confirm_delete', 'file' => $entry['file']), '_SELF');
             $link = get_custom_base_url() . '/exports/backups/' . $entry['file'];
             $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '23a8b5d5d345d8fdecc74b01fe5a9042', 'NAME' => $entry['file'], 'URL' => $delete_url));
             $type = do_lang_tempcode('UNKNOWN');
             switch (get_file_extension($entry['file'])) {
                 case 'gz':
                     $type = do_lang_tempcode('BACKUP_FILE_COMPRESSED');
                     break;
                 case 'tar':
                     $type = do_lang_tempcode('BACKUP_FILE_UNCOMPRESSED');
                     break;
                 case 'txt':
                     $type = do_lang_tempcode('BACKUP_FILE_LOG');
                     break;
                 case '':
                     $type = do_lang_tempcode('BACKUP_FILE_UNFINISHED');
                     break;
             }
             $rows->attach(table_table_row(array(hyperlink($link, escape_html($entry['file'])), $type, clean_file_size($entry['size']), get_timezoned_date($entry['mtime']), $actions)));
         }
         $files = do_template('TABLE_TABLE', array('_GUID' => '726070efa71843236e975d87d4a17dae', 'HEADER_ROW' => $header_row, 'ROWS' => $rows));
     } else {
         $files = new ocp_tempcode();
     }
     return $files;
 }