| 域名空间 下载中心 社区论坛 信息公告 my小屋 |
![]() |
联系我们 设为首页 加入收藏 |
|
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿 论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图 专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版 社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务 |
| 新版上线![旧版] | |||||
注:打开慢时请稍等
谁能给个ubb代码的转换函数?http://www.iyit.net 日期:2006-10-6 15:32:48 来源:iyit.net收集 点击: |
就是[b][/b]转化成<b></b>这样的 马上就要用 谢谢 --------------------------------------------------------------- http://expert.csdn.net/expert/faq/faq_index.asp?id=10863 以下是源代码 <?php /************************************************************ * ubb 解析器 v1.0b * * 该解释器支持的是ubb的子集(标准集我也不知到啥样) * 需要其他的可以自行扩展, * 理论上支持任何[x=a,b,c]xxx[/x]结构的解析 * * 源代码由zy提供,在此思路上重写了大部分代码 * * 如果你有什么好的建议请联系 pazee@21cn.com * 正则表达式的用法得到 z_yong@163.com 的大力支持,在此表示感谢 * 耙子 2001/12/31 * http://www.fogsun.com * * $ 转载请完整保留此段文字 $ * * 使用说明 * 1.本代码未对html进行任何限制,仅增加了对ubb-〉html的转换支持, * 如果需要请在调用本代码前自行过滤html标签, * 2.调用代码前请用 stripslashes 函数去掉转换内容中的冗余反斜杠, * 否则结果可能会出现问题 * 3.ubb 标签中不允许出现空格 *************************************************************/ define ("sversion", "1.2.1.15 beta"); //ubbcode类 class ubbcode { var $nest; // 递归深度,for debug //可处理标签及处理函数表 var $tags = array( 'url' => '$this->url', 'email' => '$this->email', 'mail' => '$this->email', // 为了容错,[mail]和[email]等效 'img' => '$this->img', 'b' => '$this->simple', 'i' => '$this->simple', 'u' => '$this->simple', 'tt' => '$this->simple', 's' => '$this->simple', 'strike' => '$this->simple', 'h1' => '$this->simple', 'h2' => '$this->simple', 'h3' => '$this->simple', 'h4' => '$this->simple', 'h5' => '$this->simple', 'h6' => '$this->simple', 'sup' => '$this->simple', 'sub' => '$this->simple', 'em' => '$this->simple', 'strong' => '$this->simple', 'code' => '$this->simple', 'samp' => '$this->simple', 'kbd' => '$this->simple', 'var' => '$this->simple', 'dfn' => '$this->simple', 'cite' => '$this->simple', 'small' => '$this->simple', 'big' => '$this->simple', 'blink' => '$this->simple', 'fly' => '$this->fly', 'move' => '$this->move', 'glow' => '$this->cssstyle', 'shadow' => '$this->cssstyle', 'blur' => '$this->cssstyle', 'wave' => '$this->cssstyle', 'sub' => '$this->simple', 'sup' => '$this->simple', 'size' => '$this->size', 'face' => '$this->face', 'font' => '$this->face', // 为了容错,[font]和[face]等效 'color' => '$this->color' ); function ubbcode() { $this->$nest= 0; $this->$slastmodified= sprintf("%s", date("y-m-j h:i", getlastmod())); } /*********************************************************************** * 对使用者输入的 e-mail 作简单的检查, * 检查使用者的 e-mail 字串是否有 @ 字元, * 在 @ 字元前有英文字母或数字,在之后有数节字串, * 最后的小数点后只能有二个或三个英文字母。 * super@mail.wilson.gs 就可以通过检查,super@mail.wilson 就不能通过检查 ************************************************************************/ function emailcheck($str) { if (eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $str)) return true; else return false; } /*********************************************************************** * 对使用者输入的 url 作简单的检查, * 目前只能简单判断,不能自动检查fpt,finger等 ************************************************************************/ function checkurl($str) { $bvalidurl= true; if (eregi("([a-z0-9-]+([\.][a-z0-9\-]+)+)", $str, $er_arr)) { /* printf ("0. %s <br>\n", $er_arr[0]); printf ("1. %s <br>\n", $er_arr[1]); printf ("2. %s <br>\n", $er_arr[2]); printf ("3. %s <br>\n", $er_arr[3]); printf ("4. %s <br>\n", $er_arr[4]); */ } else $bvalidurl= false; return $bvalidurl; } /*********************************************************************** * 对使用者输入的 图片url 作简单的检查, * 目前只能简单判断结尾是否为图片文件 * 不支持由cgi动态生成的图片,比如计数器这类的 ************************************************************************/ function checkimgurl($str) --------------------------------------------------------------- function ubb($text) { $text=htmlspecialchars($text); $text=stripslashes($text); $text=ereg_replace("\r\n","<br/>",$text); $text=ereg_replace("\r","<br/>",$text); $text=nl2br($text); $text=preg_replace("/\\t/is"," ",$text); $text=ereg_replace(" "," ",$text); $text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","<h1>\\1</h1>",$text); $text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","<h2>\\1</h2>",$text); $text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","<h3>\\1</h3>",$text); $text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","<h4>\\1</h4>",$text); $text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","<h5>\\1</h5>",$text); $text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","<h6>\\1</h6>",$text); $text=preg_replace("/\[center\](.+?)\[\/center\]/is","<center>\\1</center>",$text); $text=preg_replace("/\[big\](.+?)\[\/big\]/is","<big>\\1</big>",$text); $text=preg_replace("/\[small\](.+?)\[\/small\]/is","<small>\\1</small>",$text); $text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","<a href=\\1>\\1</a>",$text); $text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\'http://\\1\'>http://\\1</a>",$text); $text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","<a href=\\1>\\2</a>",$text); $text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","<a href=http://\\1>\\2</a>",$text); $text=preg_replace("/\[img\](.+?)\[\/img\]/is","<img src=\\1 border=0>",$text); $text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","<font color=\\1>\\2</font>",$text); $text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","<font size=\\1>\\2</font>",$text); $text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","<sup>\\1</sup>",$text); $text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","<sub>\\1</sub>",$text); $text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","<pre>\\1</pre>",$text); $text=preg_replace("/\[email\](.+?)\[\/email\]/is","<a href=mailto:\\1>\\1</a>",$text); $text=preg_replace("/\[i\](.+?)\[\/i\]/is","<i>\\1</i>",$text); $text=preg_replace("/\[b\](.+?)\[\/b\]/is","<b>\\1</b>",$text); $text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","<blockquote><font size='1' face='courier new'>quote:</font><hr>\\1<hr></blockquote>", $text); 编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部] 上一篇:谁能给出一个复制整个文件夹的函数? 下一篇:关于php中session使用的问题! 转载请注明来源:www.iyit.net 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 相关文章 | ||||
| 友情链接 | ||||||
| 设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接 |
| |||||||