當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ocp_mark_as_escaped函數代碼示例

本文整理匯總了PHP中ocp_mark_as_escaped函數的典型用法代碼示例。如果您正苦於以下問題:PHP ocp_mark_as_escaped函數的具體用法?PHP ocp_mark_as_escaped怎麽用?PHP ocp_mark_as_escaped使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ocp_mark_as_escaped函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: obfuscate_entities

/**
 * Obfuscate the given text using HTML entity encoding.
 *
 * @param  string		The text to obfuscate
 * @return string		The obfuscated version
 */
function obfuscate_entities($val)
{
    if (strpos($val, '&') !== false) {
        return $val;
    }
    // Prevent double encoding
    $out = '';
    for ($i = 0; $i < strlen($val); $i++) {
        $char = $val[$i];
        if ($char == '<') {
            $_char = '&lt;';
        } elseif ($char == '>') {
            $_char = '&gt;';
        } elseif ($char == '&') {
            $_char = '&amp;';
        } elseif ($i % 2 == 0) {
            $_char = '&#' . sprintf('%d', ord($char)) . ';';
        } else {
            $_char = '&#x' . sprintf('%x', ord($char)) . ';';
        }
        $out .= $_char;
    }
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($out);
    }
    return $out;
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:33,代碼來源:obfuscate.php

示例2: get_future_version_information

/**
 * Get information about new versions of ocPortal (or more accurately, what's wrong with this version).
 *
 * @return tempcode		Information about the installed ocPortal version
 */
function get_future_version_information()
{
    require_lang('version');
    $url = 'http://ocportal.com/version.php?version=' . rawurlencode(ocp_version_full()) . '&lang=' . rawurlencode(user_lang());
    $data = http_download_file($url, NULL, false);
    if (!is_null($data)) {
        $data = str_replace('"../upgrader.php"', '"' . get_base_url() . '/upgrader.php"', $data);
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($data);
        }
        require_code('character_sets');
        $data = convert_to_internal_encoding($data);
        $table = new ocp_tempcode();
        $lines = explode(chr(10), $data);
        foreach ($lines as $line) {
            if (trim($line) != '') {
                $table->attach(paragraph($line));
            }
        }
        $table = make_string_tempcode(preg_replace('#<p>\\s*</p>#', '', $table->evaluate()));
    } else {
        $table = paragraph(do_lang_tempcode('CANNOT_CONNECT_HOME'), 'dfsdff32ffd');
    }
    require_code('xhtml');
    /*$table->attach('<script type="text/javascript">// <![CDATA[
    		window.open(\''.$url.'\');
    	//]]></script>');*/
    return make_string_tempcode(xhtmlise_html($table->evaluate()));
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:34,代碼來源:version2.php

示例3: _urlise_lang

/**
 * URL'ise specially encoded text-acceptance language strings.
 *
 * @param  string			The language string
 * @param  mixed			The URL (either tempcode or string)
 * @param  string			The title of the hyperlink
 * @param  boolean		Whether to use a new window
 * @return tempcode		The encoded version
 */
function _urlise_lang($string, $url, $title, $new_window)
{
    $a = strpos($string, '<{');
    $b = strpos($string, '}>');
    if ($a === false || $b === false || $b < $a) {
        return make_string_tempcode($string);
    }
    $section = substr($string, $a + 2, $b - $a - 2);
    $prior = substr($string, 0, $a);
    $after = substr($string, $b + 2);
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($section);
        ocp_mark_as_escaped($prior);
        ocp_mark_as_escaped($after);
    }
    if (is_string($url)) {
        if ($url == '') {
            return protect_from_escaping($section);
        }
    } else {
        if ($url->is_empty()) {
            return protect_from_escaping($section);
        }
    }
    $out = new ocp_tempcode();
    $out->attach(protect_from_escaping($prior));
    $out->attach(hyperlink($url, protect_from_escaping($section), $new_window, false, $title));
    $out->attach(protect_from_escaping($after));
    return $out;
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:39,代碼來源:lang_urlise.php

示例4: ecommerce_get_currency_symbol

/**
 * Get the symbol of the currency we're trading in.
 *
 * @return ID_TEXT	The currency.
 */
function ecommerce_get_currency_symbol()
{
    $currency = get_option('currency');
    switch ($currency) {
        case 'USD':
            $currency = '$';
            break;
        case 'CAD':
            $currency = '$';
            break;
        case 'EUR':
            $currency = '&euro;';
            break;
        case 'GBP':
            $currency = '&pound;';
            break;
        case 'JPY':
            $currency = '&yen;';
            break;
        case 'AUD':
            $currency = '$';
            break;
    }
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($currency);
    }
    return $currency;
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:33,代碼來源:ecommerce.php

示例5: _diff_simple

function _diff_simple($old, $new, $unified = false)
{
    $diff = new Text_Diff($old, $new);
    if ($unified) {
        $renderer = new Text_Diff_Renderer_unified();
    } else {
        $renderer = new Text_Diff_Renderer_inline();
    }
    $diff_html = $rendered_diff = $renderer->render($diff);
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($diff_html);
    }
    return $diff_html;
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:14,代碼來源:diff.php

示例6: run

    /**
     * Standard modular run function. Creates custom graphics from parameters.
     *
     * @param  array		Map of hook parameters (relayed from block parameters map).
     * @param  object		The block itself (contains utility methods).
     * @return tempcode	HTML to output.
     */
    function run($map, &$block)
    {
        if (!function_exists('imagettftext') || !array_key_exists('FreeType Support', gd_info()) || @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') === false) {
            return do_lang_tempcode('REQUIRES_TTF');
        }
        if (!array_key_exists('img1', $map)) {
            $map['img1'] = 'button1';
        }
        $img_path_1 = find_theme_image($map['img1'], true, true);
        if ($img_path_1 == '') {
            return do_lang_tempcode('NO_SUCH_THEME_IMAGE', $map['img1']);
        }
        $cache_id_1 = 'rollover1_' . md5(serialize($map));
        $url_1 = $block->_do_image($cache_id_1, $map, $img_path_1);
        if (is_object($url_1)) {
            return $url_1;
        }
        if (!array_key_exists('img2', $map)) {
            $map['img2'] = 'button2';
        }
        $img_path_2 = find_theme_image($map['img2'], true, true);
        if ($img_path_2 == '') {
            return do_lang_tempcode('NO_SUCH_THEME_IMAGE', $map['img2']);
        }
        $cache_id_2 = 'rollover2_' . md5(serialize($map));
        $url_2 = $block->_do_image($cache_id_2, $map, $img_path_2);
        if (is_object($url_2)) {
            return $url_2;
        }
        $comb_id = 'rollover_' . uniqid('', true);
        $ret = '<img id="' . php_addslashes($comb_id) . '" class="gfx_text_overlay" alt="' . str_replace(chr(10), ' ', escape_html($map['data'])) . '" src="' . escape_html($url_1) . '" />';
        $ret .= '
			<script type="text/javascript">// <![CDATA[
				create_rollover("' . php_addslashes($comb_id) . '","' . php_addslashes($url_2) . '");
			//]]></script>
		';
        if (function_exists('ocp_mark_as_escaped')) {
            ocp_mark_as_escaped($ret);
        }
        return make_string_tempcode($ret);
    }
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:48,代碼來源:rollover_button.php

示例7: run

 /**
  * Standard modular run function. Creates custom graphics from parameters.
  *
  * @param  array		Map of hook parameters (relayed from block parameters map).
  * @param  object		The block itself (contains utility methods).
  * @return tempcode	HTML to output.
  */
 function run($map, &$block)
 {
     if (!function_exists('imagettftext') || !array_key_exists('FreeType Support', gd_info()) || @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') === false) {
         return do_lang_tempcode('REQUIRES_TTF');
     }
     if (!array_key_exists('img', $map)) {
         $map['img'] = 'button1';
     }
     $img_path = find_theme_image($map['img'], true, true);
     if ($img_path == '') {
         return do_lang_tempcode('NO_SUCH_THEME_IMAGE', $map['img']);
     }
     $cache_id = 'text_overlay_' . md5(serialize($map));
     $url = $block->_do_image($cache_id, $map, $img_path);
     if (is_object($url)) {
         return $url;
     }
     $ret = '<img class="gfx_text_overlay" alt="' . str_replace(chr(10), ' ', escape_html($map['data'])) . '" src="' . escape_html($url) . '" />';
     if (function_exists('ocp_mark_as_escaped')) {
         ocp_mark_as_escaped($ret);
     }
     return make_string_tempcode($ret);
 }
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:30,代碼來源:text_overlay.php

示例8: nice_get_download_category_tree

/**
 * Get a nice, formatted XHTML list extending from the root, and showing all subcategories, and their subcategories (ad infinitum). The tree bit is because each entry in the list is shown to include the path through the tree that gets to it
 *
 * @param  ?AUTO_LINK	The currently selected category (NULL: none selected)
 * @param  boolean		Whether to make the list elements store comma-separated child lists instead of IDs
 * @param  boolean		Whether to only show for what may be added to by the current member
 * @return tempcode		The list of categories
 */
function nice_get_download_category_tree($it = NULL, $use_compound_list = false, $addable_filter = false)
{
    $tree = get_download_category_tree(NULL, NULL, NULL, false, $use_compound_list, NULL, $addable_filter);
    if ($use_compound_list) {
        $tree = $tree[0];
    }
    $out = '';
    // XHTMLXHTML
    foreach ($tree as $category) {
        if ($addable_filter && !$category['addable']) {
            continue;
        }
        $selected = $category['id'] == $it;
        $line = do_template('DOWNLOAD_LIST_LINE_2', array('_GUID' => '0ccffeff5b80b1840188b839aee8d9f2', 'TREE' => $category['tree'], 'FILECOUNT' => '?'));
        $out .= '<option value="' . (!$use_compound_list ? strval($category['id']) : $category['compound_list']) . '"' . ($selected ? ' selected="selected"' : '') . '>' . $line->evaluate() . '</option>';
    }
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($out);
    }
    return make_string_tempcode($out);
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:29,代碼來源:downloads.php

示例9: nice_get_catalogue_entries_tree

/**
 * Get a nice, formatted XHTML list of entries, in catalogue category tree structure
 *
 * @param  ID_TEXT		The catalogue name
 * @param  ?AUTO_LINK	The currently selected entry (NULL: none selected)
 * @param  ?AUTO_LINK	Only show entries submitted by this member (NULL: no filter)
 * @param  boolean		Whether to only show for what may be edited by the current member
 * @return tempcode		The list of entries
 */
function nice_get_catalogue_entries_tree($catalogue_name, $it = NULL, $submitter = NULL, $editable_filter = false)
{
    $tree = get_catalogue_entries_tree($catalogue_name, $submitter, NULL, NULL, NULL, NULL, $editable_filter);
    $out = '';
    // XHTMLXHTML
    foreach ($tree as $category) {
        foreach ($category['entries'] as $eid => $etitle) {
            $selected = $eid == $it;
            $line = do_template('CATALOGUE_ENTRIES_LIST_LINE', array('_GUID' => '0ccffeff5b80b1840188b83aaee8d9f2', 'TREE' => $category['tree'], 'NAME' => $etitle));
            $out .= '<option value="' . strval($eid) . '"' . ($selected ? 'selected="selected"' : '') . '>' . $line->evaluate() . '</option>';
        }
    }
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($out);
    }
    return make_string_tempcode($out);
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:26,代碼來源:catalogues.php

示例10: ocf_get_forum_tree_secure


//.........這裏部分代碼省略.........
        // Mark it as 'huge'
    }
    if ($FORUM_TREE_SECURE_CACHE === true) {
        $forums = $GLOBALS['FORUM_DB']->query('SELECT id,f_order_sub_alpha,f_name,f_category_id,f_parent_forum,f_position FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id IS NOT NULL AND ' . db_string_equal_to('f_redirection', '') . ' AND ' . (is_null($base_forum) ? 'f_parent_forum IS NULL' : 'f_parent_forum=' . strval($base_forum)) . ' ORDER BY f_position', 200);
    } else {
        if (is_null($FORUM_TREE_SECURE_CACHE) || $FORUM_TREE_SECURE_CACHE === false) {
            $FORUM_TREE_SECURE_CACHE = $GLOBALS['FORUM_DB']->query('SELECT id,f_order_sub_alpha,f_name,f_category_id,f_parent_forum,f_position FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id IS NOT NULL AND ' . db_string_equal_to('f_redirection', '') . ' ORDER BY f_position');
        }
        foreach ($FORUM_TREE_SECURE_CACHE as $x) {
            if ($x['f_parent_forum'] === $base_forum) {
                $forums[] = $x;
            }
        }
    }
    global $M_SORT_KEY;
    $M_SORT_KEY = $order;
    uasort($forums, 'multi_sort');
    $compound_list = '';
    foreach ($forums as $forum) {
        $access = has_category_access($member_id, 'forums', strval($forum['id']));
        $cat_sort_key = '!' . (is_null($forum['f_category_id']) ? '' : strval($forum['f_category_id']));
        if ($access && $skip !== $forum['id'] && $levels !== 0) {
            $cat_bit = '';
            if (!is_null($forum['f_category_id'])) {
                global $CATEGORY_TITLES;
                if (is_null($CATEGORY_TITLES)) {
                    $CATEGORY_TITLES = collapse_2d_complexity('id', 'c_title', $GLOBALS['FORUM_DB']->query_select('f_categories', array('id', 'c_title')));
                }
                $cat_bit = array_key_exists($forum['f_category_id'], $CATEGORY_TITLES) ? $CATEGORY_TITLES[$forum['f_category_id']] : do_lang('NA');
                //if (strlen($pre.$cat_bit)>26) $cat_bit='...';
            }
            if ($field_format) {
                $pre = $tree == '' ? '' : $tree . ' > ';
                $below = ocf_get_forum_tree_secure($member_id, $forum['id'], true, $selected_forum, $pre . $forum['f_name'], $skip, $forum['f_order_sub_alpha'], $use_compound_list, NULL, $do_stats);
                if ($use_compound_list) {
                    list($below, $_compound_list) = $below;
                    $compound_list .= strval($forum['id']) . ',' . $_compound_list;
                }
                $selected = false;
                if (!is_null($selected_forum)) {
                    foreach ($selected_forum as $s) {
                        if (is_integer($s) && $s == $forum['id']) {
                            $selected = true;
                        }
                        if (is_string($s) && $s == $forum['f_name']) {
                            $selected = true;
                        }
                    }
                }
                $line = do_template('OCF_FORUM_LIST_LINE', array('_GUID' => '2fb4bd9ed5c875de6155bef588c877f9', 'PRE' => $pre, 'NAME' => $forum['f_name'], 'CAT_BIT' => $cat_bit));
                if (!array_key_exists($cat_sort_key, $out)) {
                    $out[$cat_sort_key] = '';
                }
                $out[$cat_sort_key] .= '<option value="' . (!$use_compound_list ? strval($forum['id']) : strval($forum['id']) . ',' . $_compound_list) . '"' . ($selected ? ' selected="selected"' : '') . '>' . $line->evaluate() . '</option>';
                //$out.=$below;
                if ($levels !== 0) {
                    $out[$cat_sort_key] .= $below->evaluate();
                }
            } else {
                if ($use_compound_list) {
                    $below = ocf_get_forum_tree_secure($member_id, $forum['id'], true, $selected_forum, $forum['f_name'], $skip, $forum['f_order_sub_alpha'], $use_compound_list, NULL, $do_stats);
                    list($below, $_compound_list) = $below;
                    $compound_list .= strval($forum['id']) . ',' . $_compound_list;
                }
                $element = array('id' => $forum['id'], 'compound_list' => !$use_compound_list ? strval($forum['id']) : strval($forum['id']) . ',' . $_compound_list, 'second_cat' => $cat_bit, 'title' => $forum['f_name'], 'group' => $forum['f_category_id'], 'children' => ocf_get_forum_tree_secure($member_id, $forum['id'], false, $selected_forum, $tree, $skip, false, false, $levels, $do_stats));
                if ($do_stats) {
                    $element['child_count'] = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)', array('f_parent_forum' => $forum['id']));
                }
                if (!array_key_exists($cat_sort_key, $out)) {
                    $out[$cat_sort_key] = array();
                }
                $out[$cat_sort_key][] = $element;
            }
        }
    }
    // Up to now we worked into an array, so we could benefit from how it would auto-sort into the category>forum-position ordering ocPortal uses. Now we need to unzip it
    $real_out = mixed();
    if ($field_format) {
        $real_out = '';
        foreach ($out as $str) {
            $real_out .= $str;
        }
    } else {
        $real_out = array();
        foreach ($out as $arr) {
            $real_out = array_merge($real_out, $arr);
        }
    }
    if ($field_format) {
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($real_out);
        }
        $real_out = make_string_tempcode($real_out);
    }
    if ($use_compound_list) {
        return array($real_out, $compound_list);
    } else {
        return $real_out;
    }
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:101,代碼來源:ocf_forums2.php

示例11: output_xml

    /**
     * Output an XML-RPC packet (hopefully) to the AJAX in the frontend.
     *
     * @return boolean			Success?
     */
    function output_xml()
    {
        if (count($this->parsed_input) < 1) {
            return false;
        }
        header('Content-Type: text/xml');
        header('HTTP/1.0 200 Ok');
        if (is_object($this->output[STREAM_STDCOMMAND])) {
            $this->output[STREAM_STDCOMMAND] = $this->output[STREAM_STDCOMMAND]->evaluate();
        }
        if (is_object($this->output[STREAM_STDHTML])) {
            $this->output[STREAM_STDHTML] = $this->output[STREAM_STDHTML]->evaluate();
        }
        if (is_object($this->output[STREAM_STDOUT])) {
            $this->output[STREAM_STDOUT] = $this->output[STREAM_STDOUT]->evaluate();
        }
        if (is_object($this->output[STREAM_STDERR])) {
            $this->output[STREAM_STDERR] = $this->output[STREAM_STDERR]->evaluate();
        }
        $output = '<' . '?xml version="1.0" encoding="utf-8" ?' . '>
<response>
	<result>
		<command>' . xmlentities($this->current_input) . '</command>
		<stdcommand>' . $this->output[STREAM_STDCOMMAND] . '</stdcommand>
		<stdhtml><div xmlns="http://www.w3.org/1999/xhtml">' . $this->output[STREAM_STDHTML] . '</div></stdhtml>
		<stdout>' . xmlentities($this->output[STREAM_STDOUT]) . '</stdout>
		<stderr>' . xmlentities($this->output[STREAM_STDERR]) . '</stderr>
		<stdnotifications>' . get_queued_messages() . '</stdnotifications>
	</result>
</response>';
        if ($GLOBALS['XSS_DETECT']) {
            if (ocp_is_escaped($this->output[STREAM_STDHTML])) {
                ocp_mark_as_escaped($output);
            }
        }
        echo $output;
        set_value('last_occle_command', strval(time()));
        return true;
    }
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:44,代碼來源:occle.php

示例12: db_query

 /**
  * This function is a very basic query executor. It shouldn't usually be used by you, as there are abstracted versions available.
  *
  * @param  string			The complete SQL query
  * @param  array			A DB connection
  * @param  ?integer		The maximum number of rows to affect (NULL: no limit)
  * @param  ?integer		The start row to affect (NULL: no specification)
  * @param  boolean		Whether to output an error on failure
  * @param  boolean		Whether to get the autoincrement ID created for an insert query
  * @return ?mixed			The results (NULL: no results), or the insert ID
  */
 function db_query($query, $db, $max = NULL, $start = NULL, $fail_ok = false, $get_insert_id = false)
 {
     if (!is_null($max)) {
         if (is_null($start)) {
             $max += $start;
         }
         if (strtoupper(substr($query, 0, 7)) == 'SELECT ') {
             $query .= ' FETCH FIRST ' . strval($max + $start) . ' ROWS ONLY';
         }
     }
     $results = @odbc_exec($db, $query);
     if ($results === false && !$fail_ok) {
         $err = odbc_errormsg($db);
         if (function_exists('ocp_mark_as_escaped')) {
             ocp_mark_as_escaped($err);
         }
         if (!running_script('upgrader') && get_page_name() != 'admin_import') {
             if (!function_exists('do_lang') || is_null(do_lang('QUERY_FAILED', NULL, NULL, NULL, NULL, false))) {
                 fatal_exit(htmlentities('Query failed: ' . $query . ' : ' . $err));
             }
             fatal_exit(do_lang_tempcode('QUERY_FAILED', escape_html($query), $err));
         } else {
             echo htmlentities('Database query failed: ' . $query . ' [') . $err . htmlentities(']' . '<br />' . chr(10));
             return NULL;
         }
     }
     if (strtoupper(substr($query, 0, 7)) == 'SELECT ' && !$results !== false) {
         return $this->db_get_query_rows($results);
     }
     if ($get_insert_id) {
         if (strtoupper(substr($query, 0, 7)) == 'UPDATE ') {
             return NULL;
         }
         $pos = strpos($query, '(');
         $table_name = substr($query, 12, $pos - 13);
         $res2 = odbc_exec($db, 'SELECT MAX(id) FROM ' . $table_name);
         $ar2 = odbc_fetch_row($res2);
         return $ar2[0];
     }
     return NULL;
 }
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:52,代碼來源:ibm.php

示例13: apply_tempcode_escaping_inline

/**
 * Apply whatever escaping is requested to the given value.
 *
 * @param  array			A list of escaping to do
 * @param  string			The string to apply the escapings to
 * @return string			Output string
 */
function apply_tempcode_escaping_inline($escaped, $value)
{
    global $HTML_ESCAPE_1_STRREP, $HTML_ESCAPE_2;
    foreach (array_reverse($escaped) as $escape) {
        if ($escape == ENTITY_ESCAPED) {
            $value = str_replace($HTML_ESCAPE_1_STRREP, $HTML_ESCAPE_2, $value);
        } elseif ($escape == FORCIBLY_ENTITY_ESCAPED) {
            $value = str_replace($HTML_ESCAPE_1_STRREP, $HTML_ESCAPE_2, $value);
        } elseif ($escape == SQ_ESCAPED) {
            $value = str_replace('&#039;', '\\&#039;', str_replace('\'', '\\\'', str_replace('\\', '\\\\', $value)));
        } elseif ($escape == DQ_ESCAPED) {
            $value = str_replace('&quot;', '\\&quot;', str_replace('"', '\\"', str_replace('\\', '\\\\', $value)));
        } elseif ($escape == NL_ESCAPED) {
            $value = str_replace(chr(13), '', str_replace(chr(10), '', $value));
        } elseif ($escape == NL2_ESCAPED) {
            $value = str_replace(chr(13), '', str_replace(chr(10), '\\n', $value));
        } elseif ($escape == CC_ESCAPED) {
            $value = str_replace('[', '\\[', str_replace('\\', '\\\\', $value));
        } elseif ($escape == UL_ESCAPED) {
            $value = ocp_url_encode($value);
        } elseif ($escape == UL2_ESCAPED) {
            $value = rawurlencode($value);
        } elseif ($escape == JSHTML_ESCAPED) {
            $value = str_replace(']]>', ']]\'+\'>', str_replace('</', '<\\/', $value));
        } elseif ($escape == ID_ESCAPED) {
            $value = fix_id($value);
        } elseif ($escape == CSS_ESCAPED) {
            $value = preg_replace('#[^\\w\\#\\.\\-\\%]#', '_', $value);
        } elseif ($escape == NAUGHTY_ESCAPED) {
            $value = filter_naughty_harsh($value, true);
        }
    }
    if ($GLOBALS['XSS_DETECT'] && $escaped != array()) {
        ocp_mark_as_escaped($value);
    }
    return $value;
}
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:44,代碼來源:tempcode__runtime.php

示例14: run


//.........這裏部分代碼省略.........
             $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_unsink_topic', $topic_info)) {
             $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_cascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_uncascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_open_topic', $topic_info)) {
             $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_close_topic', $topic_info)) {
             $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_edit_poll', $topic_info)) {
             $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_delete_poll', $topic_info)) {
             $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_attach_poll', $topic_info)) {
             $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>';
         }
         if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) {
             $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>';
         }
         if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) {
             $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>';
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($moderator_actions);
         }
         // Marked post actions
         $map = array('page' => 'topics', 'id' => $id);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $action_url = build_url($map, get_module_zone('topics'), NULL, false, true);
         $marked_post_actions = '';
         if (array_key_exists('may_move_posts', $topic_info)) {
             $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>';
             $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>';
         }
         if (array_key_exists('may_delete_posts', $topic_info)) {
             $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>';
         }
         if (array_key_exists('may_validate_posts', $topic_info)) {
             $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>';
         }
         if (get_value('disable_multi_quote') !== '1') {
             if ($may_reply) {
                 $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>';
             }
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($marked_post_actions);
         }
     } else {
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:67,代碼來源:topicview.php

示例15: compile_template

/**
 * Compile a template into a list of appendable outputs, for the closure-style Tempcode implementation.
 *
 * @param  string			The template file contents
 * @param  ID_TEXT		The name of the template
 * @param  ID_TEXT		The name of the theme
 * @param  ID_TEXT		The language it is for
 * @param  boolean		Whether to tolerate errors
 * @return array			A pair: array Compiled result structure, array preprocessable bits (special stuff needing attention that is referenced within the template)
 */
function compile_template($data, $template_name, $theme, $lang, $tolerate_errors = false)
{
    if (strpos($data, '{$,Parser hint: pure}') !== false) {
        return array(array('"' . php_addslashes(preg_replace('#\\{\\$,.*\\}#U', '/*no minify*/', $data)) . '"'), array());
    }
    $data = preg_replace('#<\\?php(.*)\\?' . '>#sU', '{+START,PHP}${1}{+END}', $data);
    $compilable_symbols = array('"ADDON_INSTALLED"', '"COPYRIGHT"', '"SITE_NAME"', '"BRAND_BASE_URL"', '"BRAND_NAME"', '"IMG_WIDTH"', '"IMG_HEIGHT"', '"LANG"', '"THEME"', '"VALUE_OPTION"', '"CONFIG_OPTION"');
    if (function_exists('get_option') && get_option('enable_https', true) != '1') {
        $compilable_symbols[] = '"BASE_URL"';
    }
    global $SITE_INFO;
    if (isset($SITE_INFO['no_keep_params']) && $SITE_INFO['no_keep_params'] == '1') {
        $compilable_symbols[] = '"PAGE_LINK"';
        $compilable_symbols[] = '"FIND_SCRIPT"';
    }
    require_code('lang');
    require_code('urls');
    $cl = fallback_lang();
    $bits = array_values(preg_split('#(?<!\\\\)(\\{(?=[\\dA-Z\\$\\+\\!\\_]+[\\.`%\\*=\\;\\#\\-~\\^\\|\'&/@]*))|((?<!\\\\)\\,)|((?<!\\\\)\\})#', $data, -1, PREG_SPLIT_DELIM_CAPTURE));
    // One error mail showed on a server it had weird indexes, somehow. Hence the array_values call to reindex it
    $count = count($bits);
    $stack = array();
    $current_level_mode = PARSE_NO_MANS_LAND;
    $current_level_data = array();
    $current_level_params = array();
    $preprocessable_bits = array();
    for ($i = 0; $i < $count; $i++) {
        $next_token = $bits[$i];
        if ($next_token == '') {
            continue;
        }
        if ($i != $count - 1 && $next_token == '{' && preg_match('#^[\\dA-Z\\$\\+\\!\\_]#', $bits[$i + 1]) == 0) {
            $current_level_data[] = '"{}"';
            continue;
        }
        switch ($next_token) {
            case '{':
                // Open a new level
                $stack[] = array($current_level_mode, $current_level_data, $current_level_params, NULL, NULL, NULL);
                ++$i;
                $next_token = isset($bits[$i]) ? $bits[$i] : NULL;
                if (is_null($next_token)) {
                    if ($tolerate_errors) {
                        continue;
                    }
                    warn_exit(do_lang_tempcode('ABRUPTED_DIRECTIVE_OR_BRACE', escape_html($template_name), integer_format(1 + substr_count(substr($data, 0, _length_so_far($bits, $i)), chr(10)))));
                }
                $current_level_data = array();
                switch (substr($next_token, 0, 1)) {
                    case '$':
                        $current_level_mode = PARSE_SYMBOL;
                        $current_level_data[] = '"' . php_addslashes(substr($next_token, 1)) . '"';
                        break;
                    case '+':
                        $current_level_mode = PARSE_DIRECTIVE;
                        $current_level_data[] = '"' . php_addslashes(substr($next_token, 1)) . '"';
                        break;
                    case '!':
                        $current_level_mode = PARSE_LANGUAGE_REFERENCE;
                        $current_level_data[] = '"' . php_addslashes(substr($next_token, 1)) . '"';
                        break;
                    default:
                        $current_level_mode = PARSE_PARAMETER;
                        $current_level_data[] = '"' . php_addslashes($next_token) . '"';
                        break;
                }
                $current_level_params = array();
                break;
            case '}':
                if (count($stack) == 0 || $current_level_mode == PARSE_DIRECTIVE_INNER) {
                    $literal = php_addslashes($next_token);
                    if ($GLOBALS['XSS_DETECT']) {
                        ocp_mark_as_escaped($literal);
                    }
                    $current_level_data[] = '"' . $literal . '"';
                    break;
                }
                $opener_params = array_merge($current_level_params, array($current_level_data));
                $__first_param = array_shift($opener_params);
                $_first_param = implode('.', $__first_param);
                if ($bits[$i - 1] == '') {
                    $current_level_data[] = '""';
                }
                // Return to the previous level
                $past_level_data = $current_level_data;
                $past_level_params = $current_level_params;
                $past_level_mode = $current_level_mode;
                if (count($stack) == 0) {
                    if (!$tolerate_errors) {
                        warn_exit(do_lang_tempcode('TEMPCODE_TOO_MANY_CLOSES', escape_html($template_name), integer_format(1 + _length_so_far($bits, $i))));
//.........這裏部分代碼省略.........
開發者ID:erico-deh,項目名稱:ocPortal,代碼行數:101,代碼來源:tempcode_compiler.php


注:本文中的ocp_mark_as_escaped函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。