花了一个晚上的时间看了下CVC和Discuz的数据库,写了一些SQL语句,转换过去后Discuz可以跑起来了,但还是有一点问题需要继续修正,暂且先这样吧,所以在这里试发一下。一下是全部的SQL语句:- /*
- CVC BBS 1.0 to Discuz的转换
- 说明:网上找不到CVC2Discuz的程序,所以我就用SQL语句做了一下。虽然不能完美转换(我认为有很多细节没有处理,也可能存在一定的问题),但至少在帖子、用户、附件内容上完全转换成功。下面的内容就是所有的SQL语句,已经做了简单的注释。
- Author:Rover.Tang
- Web:http://tangf.cnblogs.com http://sharesh.cn
- Mail:tfljh@163.com
- 20090824
- PS:转换前先将access转成MYSQL,推荐使用Navicat for MySQL,但导入的时候需要注意编码问题。SQL语句的执行也建议使用此工具。
- */
- --转换category,需要注意fid唯一。
- insert into cdb_forums
- (fid,type,name)
- (SELECT
- Id,'group',CategoryName
- FROM
- bbs_category)
- --board,需要注意fid唯一。如果board的id有和category的ID存在相同的情况的话,则无法完全导入,建议将转换成功后的category的ID的fid改掉。
- insert into cdb_forums
- (fid,type,name)
- (SELECT
- Id,'group',CategoryName
- FROM
- bbs_category)
- --显示board和category,也可以在上面的那个语句中就处理掉
- update cdb_forums
- set status=1
- --显示board的描述信息
- insert cdb_forumfields
- (fid,description)
- (select id,description from bbs_board)
- --导入用户。需要注意,uid不要重复和存在
- insert cdb_members
- (uid,username,password,email)
- (select uid,username,password,email from bbs_member)
- --导入用户信息,只导入签名,其余的都抛弃掉,是由于cvc的用户信息用了xml而不是数据库。
- insert into cdb_memberfields
- (uid,sightml)
- (select uid,signature from bbs_member)
- --导入用户到UC,两边需要同步,不然无法登陆
- insert uc_members
- (uid,username,password,email)
- (select uid,username,password,email from bbs_member)
- --导入用户信息到UC,其实只是建立uid与member对应
- insert uc_memberfields
- (uid)
- (select uid from bbs_member)
- --导入附件
- insert into cdb_attachments
- (aid,tid,pid,filename,filesize,attachment,downloads,isimage,uid)
- (select id,topicid,replyid,attachname,attachsize,attachpath,downloads,attachtype,uid from bbs_attach)
- --更新字段是否为图片。不是图片的DZ使用0,而CVC使用2所以将其更改为0
- update cdb_attachments
- set isimage=0
- where isimage<>1
- --更新字段description。这个字段其实更新的并不是很好,description更改为名称其实就可以了。
- update cdb_attachments
- set description=right(attachment,length(attachment)-instr(attachment,'.'))
- where instr(attachment,'.')<>0
- --更新字段filetype,bmp:image/bmp;
- update cdb_attachments
- set filetype='image/bmp'
- where description='bmp'
- update cdb_attachments
- set filetype='application/msword'
- where description='doc'
- update cdb_attachments
- set filetype='image/gif'
- where description='gif'
- update cdb_attachments
- set filetype='image/pjpeg'
- where description='jpg'
- update cdb_attachments
- set filetype='image/x-png'
- where description='png'
- update cdb_attachments
- set filetype='application/msword'
- where description='doc'
- update cdb_attachments
- set filetype='application/octet-stream'
- where description='rar'
- --更新主题
- insert into cdb_threads
- (tid,fid,author,authorid,subject,lastposter,views,replies)
- (select id,boardid,authorname,authorid,title,lastreplyauthor,views,replies from bbs_topic)
- --更新帖子
- insert into cdb_posts
- (pid,tid,author,authorid,message)
- (select id,topicid,authorname,authorid,body from bbs_reply)
- --更新posts表,将主题也放入其中
- insert cdb_posts
- (fid,tid,first,author,authorid,subject,message)
- (select boardid,id,1,authorname,authorid,title,body from bbs_topic)
- --更新posts表中的fid,就是将post的board的ID和topic的board的ID对应起来
- update cdb_posts,bbs_topic
- set cdb_posts.fid=bbs_topic.boardid
- where (cdb_posts.tid=bbs_topic.id) and (cdb_posts.fid=0)
- update cdb_posts
- set usesig=1
- update cdb_threads
- set supe_pushstatus=1
- --完成了这些以后,就可以登录后台在工具中更新缓存,更新帖子数等等,需要操作这些内容后才能看到论坛版块中的帖子,不然是看不到帖子的。
- --更新管理组
- update cdb_members,bbs_administrator
- set cdb_members.adminid=1
- where cdb_members.uid=bbs_administrator.uid
- update cdb_members,bbs_administrator
- set cdb_members.groupid=1
- where cdb_members.uid=bbs_administrator.uid
- --更新超级版主
- update cdb_members,bbs_manager
- set cdb_members.adminid=2
- where cdb_members.uid=bbs_manager.uid
- update cdb_members,bbs_manager
- set cdb_members.groupid=2
- where cdb_members.uid=bbs_manager.uid
- --更新版主
- update cdb_members,bbs_Moderator
- set cdb_members.adminid=3
- where cdb_members.uid=bbs_Moderator.uid
- update cdb_members,bbs_Moderator
- set cdb_members.groupid=3
- where cdb_members.uid=bbs_Moderator.uid
- insert into cdb_moderators
- (uid,fid)
- (select uid,boardid from bbs_Moderator)
- --更新完版主后需要在后台处理一下板块里的版主
- --更新其他用户组,这里简单处理成了新手上路。需要更新复杂一些的话,找出组的对应关系即可。
- update cdb_members
- set cdb_members.groupid=10
- where cdb_members.groupid=0
- --允许discuzcode,也就是CVC的ubbcode
- update cdb_forums
- set allowbbcode=1
- --允许笑脸图标
- update cdb_forums
- set allowsmilies=1
- --允许HTML
- update cdb_forums
- set allowhtml=1
- --更新附件,更新完成后附件自动在帖子中间。原有的附件代码就完全没用了。下面就是更新帖子内容中的附件了,更新需要分为两个部分,1是更新帖子中的图片标签内容,2是删除帖子中除了图片以外的标签内容
- update cdb_posts,bbs_reply
- set cdb_posts.attachment=1
- where cdb_posts.pid=bbs_reply.id and bbs_reply.attachids<>'' and bbs_reply.attachids<>'-1'
- /*
- TODO:
- 1,如上,更新帖子中的图片标签,删除图片以外的标签,此点来看需要写一个程序了。
- 2,用户的帖子还不在用户的管理面板中,需要做继续的检查。
- 3,。。。
- */
复制代码 |