今天在新年的最后一天,我将离开BOB,转向WordPress

昨晚花了不少的时间对这个程序转换到WordPress程序,刚好今天是除夕夜!
其实并不是BOBLOG不好,而且更新太慢,有点跟不上社会的脚步,
之前我并不太看好WP,但是在辗转了N年之后,没想到又会重新回到WordPress的大家庭中来!
唉,发一段代码,也许大家有能用到,此代码的作用是将boblog2.1.1版本中的UBB代码全部替换为WordPress3.3.1中的标签!!
其他的部分我就不发了,相信用到的人也不会太多!这里发布一下我新站的地址,
我的新站将会改用 www.iklfy.com (备案中,暂时不启用) 而本站域名将不变!
www.iklfy.com BOBLOG博客
www.iklfy.com WordPress博客
欢迎大家前往我的新博客,目前数据已经完整迁移过去了!
<?php
/**
* @author Seraphim
* @copyright 2012
*/
function ConvertText($content)
{ //日志正文,UBB转HTML
$basicubb_search = array('[hr]', '<br />', '[u]', '[/u]', '[b]', '[/b]', '[i]', '[/i]', '[separator]', '[newpage]');
$basicubb_replace = array('<hr/>', '<br />', '<u>', '</u>', '<b>', '</b>', '<i>', '</i>', '<!--more-->', '<!--nextpage-->');
$content = str_replace($basicubb_search, $basicubb_replace, $content);
//将[UBB]替换为<HTML>语法
$content = preg_replace("/\[url=([^\[]*)\]\[img( align=L| align=M| align=R)?( width=[0-9]+)?( height=[0-9]+)?\]\s*(\S+?)\s*\[\/img\]\[\/url\]/ise", "makeimgwithurl('\\1', '\\2', '\\3', '\\4', '\\5')", $content);
$content = preg_replace("/\[img( align=L| align=M| align=R)?( width=[0-9]+)?( height=[0-9]+)?\]\s*(\S+?)\s*\[\/img\]/ise", "makeimg('\\1', '\\2', '\\3', '\\4')", $content);
$content = preg_replace("/\[(wmp|swf|real|flv)=([^\[\<]+?),([^\[\<]+?)\]\s*([^\[\<\r\n]+?)\s*\[\/(wmp|swf|real|flv)\]/ise", "makemedia('\\1', '\\4', '\\2', '\\3')", $content);
//$content 的值正则替换后重新赋值为$content
$regubb_search = array( //查询符合以下条件的内容
"/\[size=([^\[\<]+?)\](.+?)\[\/size\]/ie", "/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is",
"/\s*\[quote=(.+?)\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is", "/\[url\]([^\[]*)\[\/url\]/ie",
"/\[url=www.([^\[\"']+?)\](.+?)\[\/url\]/is", "/\[url=([^\[]*)\](.+?)\[\/url\]/is",
"/\[email\]([^\[]*)\[\/email\]/is", "/\[acronym=([^\[]*)\](.+?)\[\/acronym\]/is",
"/\[color=([a-zA-Z0-9#]+?)\](.+?)\[\/color\]/i", "/\[font=([^\[\<:;\(\)=&#\.\+\*\/]+?)\](.+?)\[\/font\]/i",
"/\[p align=([^\[\<]+?)\](.+?)\[\/p\]/i", "/\[b\](.+?)\[\/b\]/i", "/\[i\](.+?)\[\/i\]/i",
"/\[u\](.+?)\[\/u\]/i", "/\[strike\](.+?)\[\/strike\]/i", "/\[sup\](.+?)\[\/sup\]/i",
"/\[sub\](.+?)\[\/sub\]/i", "/\s*\[php\][\n\r]*(.+?)[\n\r]*\[\/php\]\s*/ie", "/\[code\](.+?)\[\/code\]/ie",
);
$regubb_replace = array( //将查询到符合条件的内容替换为以下代码
"makefontsize('\\1', '\\2')", "<div class=\"quote\"><div class=\"quote-title\">{$lnc[265]}</div><div class=\"quote-content\">\\1</div></div>",
"<div class=\"quote\"><div class=\"quote-title\">{$lnc[266]} \\1</div><div class=\"quote-content\">\\2</div></div>",
"makeurl('\\1')", "<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",
"<a href=\"\\1\" target=\"_blank\">\\2</a>", "<a href=\"mailto:\\1\">\\1</a>",
"<acronym title=\"\\1\">\\2</acronym>", "<span style=\"color: \\1;\">\\2</span>",
"<span style=\"font-family: \\1;\">\\2</span>", "<p align=\"\\1\">\\2</p>",
"<strong>\\1</strong>", "<em>\\1</em>", "<u>\\1</u>", "<del>\\1</del>", "<sup>\\1</sup>",
"<sub>\\1</sub>", "xhtmlHighlightString('\\1')", "CoolCode('\\1')",
);
$content = preg_replace($regubb_search, $regubb_replace, $content);
//进行替换
$content = str_replace("'", "&#39;", $content);
//将HTML 十进制代码转换
$content = nl2br($content);
//插入换行符
$content = str_replace("\r", "", $content);
$content = str_replace("\n", "", $content);
//删除 \r\n符
return $content;
//返回$content内容
}
?>

评论列表

厨房洗菜盆
2012年了,祝新年快乐,龙年万事如意
2012-01-23 18:46:06
cxd44
www.iklfy.com WordPress博客 这里的www.iklfy.com超链接错误,修正下。 我早就说wp很好,你偏要剑走偏锋,现在还不是再回来。 顺祝新年快乐,顺便弄上我的友链~~超链接没错,那个地址是我暂时用的, www.iklfy.com 等节后上班了备案下来再启用的!
2012-01-23 01:40:17