|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
function ubb2xhtml($ubb) { $flash=<<<END <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="%1$d" height="%2$d"> <param name="movie" value="%3$s" /> <param name="quality" value="high" /> <embed src="%3$s" width="%1$d" height="%2$d" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed> </object> END; $match = array ( \\'%[url=([^s]+)](.*?)[/url]%s\\', \\'%[email=([^s])+](.*?)[/email]%i\\', \\'%[img width=(d+) height=(d+)](.*?)[/img]%s\\', \\'%[img=([^s]+)/]%s\\', \\'%[flash width=(d+) height=(d+)](.*?)[/flash]%se\\', \\'%[(b|i|u|strike|sup|sub)](.*?)[/1]%s\\', \\'%[h([1-6])](.*?)[/h1]%s\\', \\'%[hr/]%s\\', \\'%[color=([^s]+)](.*?)[/color]%s\\', \\'%[font=([^"]+)](.*?)[/font]%s\\', \\'%[size=([^s]+)](.*?)[/size]%s\\', \\'%[align=(center|right|left)](.*?)[/align]%s\\', \\'%[valign=(middle|top|bottom)](.*?)[/valign]%s\\', /* \\'%[ul](.*?)[/ul]%s\\', \\'%[ul=(circle|disc|square)](.*?)[/ul]%s\\', \\'%[ol](.*?)[/ol]%s\\', \\'%[ol type=([aAiI1]) start=([a-zA-Z1-9])](.*?)[/ol]%s\\', \\'%[li](.*?)[/li]%s\\', */ \\'%[table=([^s]+?)](.*?)[/table]%s\\', \\'%[caption](.*?)[/caption]%s\\', \\'%[tr=([^s]+?)](.*?)[/tr]%s\\', \\'%[th](.*?)[/th]%s\\', \\'%[td](.*?)[/td]%s\\', \\'%[note](.*?)[/note]%s\\', \\'%[quote=(.*?)](.*?)[/quote]%s\\', \\'%[code](.*?)[/code]%s\\', \\'%[ ]{2}%s\\', // make double-spaces truly double-spaces! ); $replace = array ( \\'<a href="1" target="_blank">2</a>\\', \\'<a href="mailto:1" target="_blank">2</a>\\', \\'<img src="3" width="1" height="2" border="0" />\\', \\'<img src="1" border="0" />\\', \\'sprintf("$flash", "1", "2", "3")\\', \\'<1>2</1>\\', \\'<h1>2</h1>\\', \\'<hr>n\\', \\'<font color="1">2</font>\\', \\'<font face="1">2</font>\\', \\'<font size="1">2</font>\\', \\'<div align="1">2</font>\\', \\'<div valign="1">2</font>\\', /* \\'<ul>1</ul>\\', \\'<ul type="1">2</ul>\\', \\'<ol>1</ol>\\', \\'<ol type="1" start="2">3</ol>\\', \\'<li>1</li>\\', */ "<table class="$1" cellspacing="1">n$2</table>", "t<caption>$1</caption>n", "t<tr class="$1">n$2t</tr>n", "tt<th>$1</th>n", "tt<td>$1</td>n", \\'<div class="note"><span class="hint">发布者备注</span><hr />1</div>\\', \\'<div class="quote"><span class="hint">引用</span>(来源: <a href="1" target="_blank">1</a>)<br />2</div>\\', \\'<span class="hint" style="margin-left: 10px">代码</span><div class="code">1</div>\\', \\' \\', ); if( preg_match(\\'%[table=(.*?)/table]%s\\', $ubb, $tablecells) ) //假如有表格, 先去除单元格之间的多余空白 { $bb=preg_replace(\\'%]([rns]*)[%si\\', \\'][\\', $tablecells[1]); $ubb=str_replace($tablecells[1], $bb, $ubb); } $html = preg_replace($match, $replace, nl2br(htmlspecialchars($ubb))); $html = preg_replace(\\'/<br />s*<(td|th|tr|table|ul|ol|li)/m\\', "n".\\'<1\\', $html); return $html; } 返回类别: 教程 上一教程: 桌面中央(一) 创建数据库 下一教程: vBulletin HACK----关于排版的两个HACK 您可以阅读与"自己写的一个UBB转变的函数"相关的教程: · 一个ubbcode的函数,速度很快. · 一个阿拉伯数字转中文数字的函数 · 一个查看session内容的函数 · 一个取得文件扩展名的函数 · 自己写的mysql类 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |