转换vbb 3.0.3到phpbb3

集思学院已经用了很长时间的vbb3.0.3,现在有些功能在我们的服务器已经出问题了,而且不想再跟vbb了,因为数字流域论坛已经转换到phpbb了,为了以后维护方便,决定从vbb3.0.3转换到phpbb 3 rc1。(估计RC2版本就要出来了,BUG已经很少了)

因为之前已经写了一个webwiz到phpbb的转换程序,所以再写vbb3到phpbb3的转换程序,比上次要轻松不少,但webwiz的设计思想就是来源于phpbb,所以很多库结构都非常像,而vbb的结构和phpbb有较大差异,在调试过程中还是耗费了大量的时间,回头来看,大约耗费了有一个礼拜的时间。感觉我都能提供有偿论坛转换服务了,哈哈。

转换过程:
首先要进行数据库的UTF8转换。之前论坛采用的是gb2312编码,但论坛上有台湾的注册用户,原来也能显示繁体中文,所以应该采用的是gbk或gb18030的编码。
在进行数据库的备份之前,要在原来的vb论坛后台把附件的存贮方式修改为文件方式,上传头像的存贮方式也修改为文件方式,而customprofilepic我没有找到对应的phpbb设置,所以这一块就直接丢弃了。
然后导出数据库:

mysql -uroot --add-drop-table --default-character-set=utf8 cngis > cngis.sql

进行编码的转换:

iconv -c -f gb18030 -t utf8 cngis.sql > cngisutf8.sql

然后修改此sql文件,替换所有的utf8为utf8,并在文件的开始处添加:


SET NAMES utf8;
SET CHARACTER_SET_CLIENT=utf8;
SET CHARACTER_SET_RESULTS=utf8;

然后新建一个数据库cngisutf8,作为我们的测试数据库并尝试导入此sql文件。

mysql -uroot cngisutf8 < cngisutf8.sql

若在导入过程中没有错误,那么恭喜你,你太幸运了。
我在这一步中遇到错误,导致我以为是中文编码的问题,还以为繁体中文无法正常转换过来呢,后来经过多次测试,发现是转换后的sql文件里存在歧义字符:

\'

导致mysql无法导入,若你也有这个问题,直接去掉那个反斜线就可以了。

安装一个全新的phpbb3。

拷贝我写的vbb3.0.x转换器到phpbb3的install/convertors目录下,并运行相应的转换程序。
在我的转换程序中,给phpbb3默认的数据库结构中添加了两个字段:
一个是users表里添加了一个salt字段,这个是为了无缝转换论坛密码使用的。
一个是topics表里添加了一个goodnees字段,这个是因为我原来的vbb3中使用了精华插件,若你没有使用,可以把相关部分注释掉。
修改论坛的登录程序,使原来的用户可以直接登录,就是修改includes/auth/auth_db.sql文件。

// Check password ...
// added for vb3 conversion
if (!$row['user_pass_convert'] && (md5($password) == $row['user_password']
or md5(md5($password).$row['salt'])==$row['user_password']))
{
if (md5($password)!=$row['user_password'])
{
// Unconverted password
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_password = "'.md5($password).'"
WHERE user_id = ' . $row['user_id'];
$db->sql_query($sql);
}

if ($row['user_login_attempts'] != 0)
{
// Successful, reset login attempts (the user passed all stages)
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_login_attempts = 0
WHERE user_id = ' . $row['user_id'];
$db->sql_query($sql);
}

同时,前面的$sql语句中要添加一个字段:salt。
或者,也可以直接使用我提供的auth_db.php文件。

要注意,这个转换程序对自定义头像导入的功能不细致,还需要进一步处理,但我的论坛上已经够用了,若你的论坛有问题,请反馈给我。
同时,对用户的多组功能也不细致,因为我的论坛上只有2个用户是多组,而且只多1个组,因此转换程序在这儿也进行了简化。
在使用时,请根据自己的实际情况作调整!

授权:GPL2
致谢:
1. shely@ubuntu-cn irc,在编码转换问题上提供了大力帮助。
2. vb3_2phpbb的转换程序,在遇到问题时,首先就参考了这个转换程序。

下载:vb3.0.x convertor


已发布

分类

,

来自

标签:

评论

《“转换vbb 3.0.3到phpbb3”》 有 18 条评论

  1. wlx 的头像
    wlx

    果然,phpbb 3 rc2今天发布了!

  2. wlx 的头像
    wlx

    发现是“受益非淺”这儿产生的问题
    应该是这个“淺”字在转换时多出了\符号,导致问题的产生。

  3. Patty 的头像
    Patty

    请问大哥有dz550 转PHPBB3的吗?? 请大哥帮帮忙 小弟十分喜欢PHPBB!

  4. wlx 的头像
    wlx

    To Patty:
    sorry,我没有用过dz5。
    不过,你可以对照我的转换程序,自己修改。或者通过第三方论坛来进行转换,如dz5->vb->phpbb3

  5. wlx 的头像
    wlx

    BUG:
    无法转换二级子论坛,即分类-子论坛-子论坛无法转换,但可以通过新建版面,然后修改forum_id为原子论坛的forum_id来修复。
    其他内容无丢失。

  6. 老鬼 的头像

    在官方看到你的帖子,不知道vb 3.6能不能转。

  7. wlx 的头像
    wlx

    vb 3.0到3.6,数据结构应该有很大变化,所以应该不行。

  8. TobSnyder 的头像
    TobSnyder

    it does not work with vB 3.6.7 an phpBB3 RC4 – I got the following error:

    SQL ERROR [ mysql4 ]

    Can’t DROP ‘goodnees’; check that column/key exists [1091]

    SQL

    ALTER TABLE phpbb_topics DROP COLUMN goodnees

    BACKTRACE

    FILE: includes/db/mysql.php
    LINE: 133
    CALL: dbal->sql_error()

    FILE: install/install_convert.php
    LINE: 1104
    CALL: dbal_mysql->sql_query()

    FILE: install/install_convert.php
    LINE: 203
    CALL: install_convert->convert_data()

    FILE: install/index.php
    LINE: 362
    CALL: install_convert->main()

    FILE: install/index.php
    LINE: 234
    CALL: module->load()

  9. wlx 的头像
    wlx

    To TobSynder:
    this convertor does not work with vb 3.6.x, and your errors with this convertor is about a mod with my vb forum, just comment all ‘goodnees’ related sentence in the convertor will fix this bug.

  10. TobSnyder 的头像
    TobSnyder

    ah ok I did not know that it does not work with vB 3.6.x – will there a new version soon, supporting vb 3.6.x and newset phpBB3 (RC4)? Would be great!!! I really appreciate your work!

    If you are interested:

    by commenting all “goodnees” related sentence I got another error, but thread / topic informations are converted…

    SQL ERROR [ mysql4 ]

    Unknown column ‘pm.pmid’ in ‘order clause’ [1054]

    SQL

    SELECT pmtext.pmtextid, pmtext.fromuserid AS poster_id, pmtext.iconid, pmtext.dateline, pmtext.allowsmilie AS enable_smilies, pmtext.showsignature, pmtext.title, pmtext.dateline AS post_time, pmtext.message, pmtext.touserarray FROM pmtext ORDER BY pm.pmid LIMIT 2000

    BACKTRACE

    FILE: includes/db/mysql.php
    LINE: 133
    CALL: dbal->sql_error()

    FILE: includes/db/mysql.php
    LINE: 180
    CALL: dbal_mysql->sql_query()

    FILE: includes/db/dbal.php
    LINE: 145
    CALL: dbal_mysql->_sql_query_limit()

    FILE: install/install_convert.php
    LINE: 1234
    CALL: dbal->sql_query_limit()

    FILE: install/install_convert.php
    LINE: 203
    CALL: install_convert->convert_data()

    FILE: install/index.php
    LINE: 362
    CALL: install_convert->main()

    FILE: install/index.php
    LINE: 234
    CALL: module->load()

  11. Christian 的头像

    when try converting my VB 3.6.8 DB to PHPBB3 it hangs and never completes. Is this thing compatible with the above versions?

  12. wlx 的头像
    wlx

    To Christian:
    This convertor could not work with vb 3.5.x or 3.6.x, I just convert my a vb 3.0.x forum with this convertor.

  13. 老鬼 的头像

    现在phpbb3.0正式版也出了,希望能改成vb 3.6转phpbb 3.0

  14. Fadi 的头像
    Fadi

    hi man :)

    i have vb 3.8.1 can i convert it to phpbb ..
    &
    database’s encoding to utf8 how can i do
    pleas help me
    thanx alot

  15. wlx 的头像
    wlx

    @Fadi:
    This convertor should not be used with vbb 3.8, just because the vbb 3.0 version is the only version I have tested.

    Maybe you should modify my code to make it suitable with vbb 3.8.

  16. wlx 的头像
    wlx

    If you could not read Chinese ( I explain the encode conversion in Chinese), you need iconv tool to convert the encoding.

  17. Fadi 的头像
    Fadi

    i can’t read Chinese :(

    thnkx man

  18. […] or you can simple replace it with old one. BTW 1: There is a chinese version, in my blog: LiangXu Wang Blog Archive ??vbb 3.0.3?phpbb3 BTW 2: I could not upload the attachment now, so you can download it in my blog. […]

回复 wlx 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注