Exemple #1
0
function rhtmlspecialchars($string, $flags = null)
{
    if (is_array($string)) {
        foreach ($string as $key => $val) {
            $string[$key] = rhtmlspecialchars($val, $flags);
        }
    } else {
        if (is_numeric($string)) {
            return $string;
        }
        if ($flags === null) {
            $string = str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $string);
            if (strpos($string, '&amp;#') !== false) {
                $string = preg_replace('/&amp;((#(\\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string);
            }
        } else {
            if (PHP_VERSION < '5.4.0') {
                $string = htmlspecialchars($string, $flags);
            } else {
                if (strtolower(CHARSET) == 'utf-8') {
                    $charset = 'UTF-8';
                } else {
                    $charset = 'ISO-8859-1';
                }
                $string = htmlspecialchars($string, $flags, $charset);
            }
        }
    }
    return $string;
}
Exemple #2
0
/**
 * 显示一个编辑器项
 * @param string $title 表单项标题
 * @param string $name 表单项名称
 * @param string $value 编辑器内容
 * @param string $comment 描述信息
 */
function tpl_form_field_editor($title, $name, $value = '', $comment = '') {
	static $editorid = 0;
	$editorid++;
	$s = '
	<link rel="stylesheet" href="kindeditor/skins/default.css" type="text/css" media="all" />
	<script type="text/javascript" src="static/kindeditor/kindeditor-min.js"></script>
	<script>
	KE.show({
		id : "editor' . $editorid . '",
		resizeMode:1,
		allowUpload:false,
		urlType:\'absolute\',
		items : [\'bold\',\'italic\',\'underline\',\'strikethrough\',\'textcolor\',\'bgcolor\',\'fontname\',\'fontsize\',\'removeformat\',\'wordpaste\',\'insertorderedlist\',\'insertunorderedlist\',\'indent\',\'outdent\',\'justifyleft\',\'justifycenter\',\'justifyright\',\'link\',\'unlink\',\'image\',\'flash\',\'advtable\',\'emoticons\',\'source\']
	});
	</script>
	<textarea name="' . $name . '" id="editor' . $editorid . '" style="width:600px;height:150px;">' . rhtmlspecialchars($value) . '</textarea>';
	tpl_form_field($title, $name, $s, $comment);
}