&lt;?php<br /> function get_ubb($str) {<br /> <br /> $str = preg_replace(&quot;/(\[)em(.*?)(\])/i&quot;, &quot;&lt;img src=\&quot;emot/em\\2.gif\&quot; /&gt;&quot;, $str);<br /> //链接UBB<br /> $str = preg_replace(&quot;/(\[url\])(.*)(\[\/url\])/i&quot;, &quot;&lt;a href=\\2 <br /> <br /> target=\&quot;new\&quot;&gt;\\2&lt;/a&gt;&quot;, $str);<br /> //QQ号码UBB<br /> $str = preg_replace(&quot;/\[qq\]([0-9]*)\[\/qq\]/i&quot;, &quot;&lt;a target=\&quot;_blank\&quot; <br /> <br /> href=\&quot;tencent://message/?uin=\${1}&amp;amp;site=www.php100.com&amp;amp;menu=yes\&quot;&gt;&lt;img <br /> <br /> src=\&quot;http://wpa.qq.com/pa?p=1:\${1}:8\&quot; alt=\&quot;QQ\${1}\&quot; height=\&quot;16\&quot; border=\&quot;0\&quot; <br /> <br /> align=\&quot;top\&quot; /&gt;&lt;/a&gt;&quot;, $str);<br /> <br /> return $str;<br /> }<br /> <br /> if($_POST['sub']){<br /> echo get_ubb($_POST[message]);<br /> }<br /> <br /> <br /> ?&gt;<br /> &lt;script&gt;<br /> function inserttag(topen,tclose){<br /> var themess = document.getElementById('con');//编辑对象<br /> themess.focus();<br /> if (document.selection) {//如果是否ie浏览器<br /> var theSelection = document.selection.createRange().text;//获取选区文字<br /> //alert(theSelection);<br /> if(theSelection){<br /> document.selection.createRange().text = theSelection = topen+theSelection+tclose;//替<br /> <br /> 换<br /> }else{<br /> document.selection.createRange().text = topen+tclose;<br /> }<br /> theSelection='';<br /> <br /> }else{//其他浏览器<br /> <br /> var scrollPos = themess.scrollTop;<br /> var selLength = themess.textLength;<br /> var selStart = themess.selectionStart;//选区起始点索引,未选择为0<br /> var selEnd = themess.selectionEnd;//选区终点点索引<br /> if (selEnd &lt;= 2)<br /> selEnd = selLength;<br /> <br /> var s1 = (themess.value).substring(0,selStart);//截取起始点前部分字符<br /> var s2 = (themess.value).substring(selStart, selEnd)//截取选择部分字符<br /> var s3 = (themess.value).substring(selEnd, selLength);//截取终点后部分字符<br /> <br /> themess.value = s1 + topen + s2 + tclose + s3;//替换<br /> <br /> themess.focus();<br /> themess.selectionStart = newStart;<br /> themess.selectionEnd = newStart;<br /> themess.scrollTop = scrollPos;<br /> return;<br /> }<br /> }<br /> &lt;/script&gt;<br /> &lt;hr/&gt;<br /> &lt;font size=2&gt;<br /> &lt;img src=&quot;emot/em_01.gif&quot; onclick='inserttag(&quot;[em_01&quot;,&quot;]&quot;);' /&gt;<br /> &lt;img src=&quot;emot/em_02.gif&quot; onclick='inserttag(&quot;[em_02&quot;,&quot;]&quot;);' /&gt;<br /> &lt;img src=&quot;emot/em_03.gif&quot; onclick='inserttag(&quot;[em_03&quot;,&quot;]&quot;);' /&gt;<br /> &lt;img src=&quot;emot/em_04.gif&quot; onclick='inserttag(&quot;[em_04&quot;,&quot;]&quot;);' /&gt;<br /> &lt;img src=&quot;emot/em_05.gif&quot; onclick='inserttag(&quot;[em_05&quot;,&quot;]&quot;);' /&gt;<br /> &lt;img src=&quot;emot/em_06.gif&quot; onclick='inserttag(&quot;[em_06&quot;,&quot;]&quot;);' /&gt;<br /> &lt;img src=&quot;emot/em_07.gif&quot; onclick='inserttag(&quot;[em_07&quot;,&quot;]&quot;);' /&gt;<br /> &lt;img src=&quot;emot/em_08.gif&quot; onclick='inserttag(&quot;[em_08&quot;,&quot;]&quot;);' /&gt;<br /> &lt;a href=&quot;javascript:void(0);&quot; onclick='inserttag(&quot;<b>&quot;,&quot;</b>&quot;);'&gt;加粗&lt;/a&gt;<br /> &lt;a href=&quot;javascript:void(0);&quot; onclick='inserttag(&quot;[qq]&quot;,&quot;[/qq]&quot;);'&gt;QQ号&lt;/a&gt;<br /> &lt;a href=&quot;javascript:void(0);&quot; onclick='inserttag(&quot;<a href=&quot;,&quot; target="new">&quot;,&quot;</a>&quot;);'&gt;超链接&lt;/a&gt;<br /> &lt;br&gt;<br /> <br /> &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;<br /> &lt;textarea name=&quot;message&quot; id=&quot;con&quot; cols=&quot;70%&quot; rows=&quot;10&quot;&gt;&lt;/textarea&gt;<br /> &lt;input type=&quot;submit&quot; name=&quot;sub&quot; value=&quot;提交&quot;/&gt;<br /> &lt;/form&gt;
T:0.007410s,M:211.48 KB
返回顶部 留言