<?php
function get_ubb($str) {
//$str = preg_replace("/(/[)em(.*?)(/])/i", "<img src=/"ubb///2.gif/" />", $str);
//表情UBB U禁止贪婪匹配,只跟踪到最近的一个匹配符并结束。
$str = preg_replace("//[em_(.*)/]/iU","<img src=/"ubb///1.gif/" />",$str);
//加粗UBB
$str = preg_replace("//[b/](.*)/[//b/]/i","<b>//1</b>",$str);
//链接UBB
$str = preg_replace("/(/[url/])(.*)(/[//url/])/i", "<a href=//2 target=/"new/">//2</a>", $str);
//QQ号码UBB
$str = preg_replace("//[qq/]([0-9]*)/[//qq/]/i", "<a target=/"_blank/" href=/"tencent://message/?uin=/${1}&site=www.php100.com&menu=yes/"><img src=/"http://wpa.qq.com/pa?p=1:/${1}:8/" alt=/"QQ/${1}/" height=/"16/" border=/"0/" align=/"top/" /></a>", $str);
return $str;
}
if($_POST['sub']){
echo get_ubb($_POST[message]);
}
?>
<script>
function inserttag(topen,tclose){
var themess = document.getElementByIdx_x('con');//编辑对象
themess.focus();
if (document.selection) {//如果是否ie浏览器
var theSelection = document.selection.createRange().text;//获取选区文字
//alert(theSelection);
if(theSelection){
document.selection.createRange().text = theSelection = topen+theSelection+tclose;//替换
}else{
document.selection.createRange().text = topen+tclose;
}
theSelection='';
}else{//其他浏览器
var scrollPos = themess.scrollTop;
var selLength = themess.textLength;
var selStart = themess.selectionStart;//选区起始点索引,未选择为0
var selEnd = themess.selectionEnd;//选区终点点索引
if (selEnd <= 2)
selEnd = selLength;
var s1 = (themess.value).substring(0,selStart);//截取起始点前部分字符
var s2 = (themess.value).substring(selStart, selEnd)//截取选择部分字符
var s3 = (themess.value).substring(selEnd, selLength);//截取终点后部分字符
themess.value = s1 + topen + s2 + tclose + s3;//替换
themess.focus();
themess.selectionStart = newStart;
themess.selectionEnd = newStart;
themess.scrollTop = scrollPos;
return;
}
}
</script>
<hr/>
<font size=2>
<img src="ubb/bizui.gif" onclick='inserttag("[em_bizui","]");' />
<img src="ubb/chiya.gif" onclick='inserttag("[em_chiya","]");' />
<img src="ubb/diaopi.gif" onclick='inserttag("[em_diaopi","]");' />
<img src="ubb/ku.gif" onclick='inserttag("[em_ku","]");' />
<img src="ubb/liuhan.gif" onclick='inserttag("[em_liuhan","]");' />
<img src="ubb/liulei.gif" onclick='inserttag("[em_liulei","]");' />
<img src="ubb/se.gif" onclick='inserttag("[em_se","]");' />
<img src="ubb/touxiao.gif" onclick='inserttag("[em_touxiao","]");' />
<img src="ubb/weixiao.gif" onclick='inserttag("[em_weixiao","]");' />
<img src="ubb/yun.gif" onclick='inserttag("[em_yun","]");' />
<a href="javascript:void(0);" onclick='inserttag("[b]","[/b]");'>加粗</a>
<a href="javascript:void(0);" onclick='inserttag("[qq]","[/qq]");'>QQ号</a>
<a href="javascript:void(0);" onclick='inserttag("[url]","[/url]");'>超链接</a>
<br>
<form action="" method="post">
<textarea name="message" id="con" cols="70%" rows="10"></textarea>
<input type="submit" name="sub" value="提交"/>
</form>
图片所在的位置
ubb文件夹下面
新闻热点
疑难解答