Supesite7.0 转换导入phpcms 2008 sp3的方法

前端之家收集整理的这篇文章主要介绍了Supesite7.0 转换导入phpcms 2008 sp3的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

前些天,写了一个PHP脚本用于supesite7.0导入PHPcms2008:

<?PHP @H_301_3@/* @H_301_3@supesite7.0导入PHPcms 2008 sp3 导入脚本 @H_301_3@warran@qq.com @H_301_3@http://www.veryhuo.com@H_301_3@*/ @H_301_3@header("Content-Type: text/html;charset=utf-8"); @H_301_3@set_time_limit(0); @H_301_3@define('IN_ADMIN',TRUE); @H_301_3@define('IN_PHPCMS',TRUE); @H_301_3@require_once '../include/common.inc.PHP'; @H_301_3@require_once '../include/admin/process.class.PHP'; @H_301_3@require '../include/priv_role.class.PHP'; @H_301_3@require_once '../include/attachment.class.PHP'; @H_301_3@require_once '../include/admin/content.class.PHP'; @H_301_3@//数据库连接 @H_301_3@//conn1为supesite数据库 @H_301_3@//conn2为PHPcms数据库 @H_301_3@$conn1=MysqL_connect("localhost","root",""); @H_301_3@MysqL_select_db("site",$conn1); @H_301_3@$conn2=MysqL_connect("localhost",""); @H_301_3@MysqL_select_db("PHPcms",$conn2); @H_301_3@//清空PHPcms 文章评论数据 @H_301_3@if($_GET["action"]=='clean'){ @H_301_3@MysqL_query("delete from PHPcms_content where 1=1",$conn2); @H_301_3@MysqL_query("delete from PHPcms_content_count where 1=1",$conn2); @H_301_3@MysqL_query("delete from PHPcms_c_news where 1=1",$conn2); @H_301_3@MysqL_query("delete from PHPcms_content_tag where 1=1",$conn2); @H_301_3@MysqL_query("delete from PHPcms_keyword where 1=1",$conn2); @H_301_3@MysqL_query("delete from PHPcms_member_group_priv where 1=1",$conn2); @H_301_3@MysqL_query("delete from PHPcms_comment where 1=1",$conn2); @H_301_3@exit("清空完成"); @H_301_3@} @H_301_3@if($_GET["action"]=='test'){ @H_301_3@echo hasuser("warran"); @H_301_3@exit(); @H_301_3@} @H_301_3@//读取分类表 @H_301_3@$result=MysqL_query("select catid,catname from PHPcms_category",$conn2); @H_301_3@while($row=MysqL_fetch_array($result)){ @H_301_3@$cat["$row[catname]"]=$row[catid]; @H_301_3@} @H_301_3@$_roleid = cache_read('admin_role_'.$_userid.'.PHP'); @H_301_3@$priv_role = new priv_role(); @H_301_3@$c = new content(); @H_301_3@$tmp=0; @H_301_3@//添加文章 @H_301_3@$result=MysqL_query("select supe_spaceitems.*,supe_categories.name as catname from supe_spaceitems,supe_categories where supe_spaceitems.catid=supe_categories.catid and supe_spaceitems.folder=1",$conn1); @H_301_3@while($row=MysqL_fetch_array($result)){ @H_301_3@//使用PHPcms自带的类,添加内容 @H_301_3@$data["catid"]=$cat[$row["catname"]]; @H_301_3@$attachment = new attachment("PHPcms",$data["catid"]); @H_301_3@$data["title"]=addslashes($row["subject"]); @H_301_3@$data["style"]=""; @H_301_3@$data["thumb"]=""; @H_301_3@$res=MysqL_query("select * from supe_spacenews where itemid=$row[itemid]",$conn1); @H_301_3@$includetags=""; @H_301_3@$message=""; @H_301_3@while($rs=MysqL_fetch_array($res)){ @H_301_3@$message.=$rs["message"]; @H_301_3@if($rs["includetags"]!=''){ @H_301_3@$includetags.=" ".$rs["includetags"]; @H_301_3@} @H_301_3@} @H_301_3@$data["keywords"]=addslashes($includetags); @H_301_3@$data["author"]=addslashes($row["username"]); @H_301_3@$data["copyfrom"]=addslashes($row["newsauthor"]); @H_301_3@$data["description"]=""; @H_301_3@$data["content"]=addslashes($message); @H_301_3@$data["paginationtype"]="0"; @H_301_3@$data["maxcharperpage"]="10000"; @H_301_3@$data["titleintact"]=addslashes($row["short_subject"]); @H_301_3@$data["islink"]="99"; @H_301_3@$time_tmp=date("Y-m-d h:i:s"); @H_301_3@$data["inputtime"]=$time_tmp; @H_301_3@$data["posids"]="-99"; @H_301_3@$data["groupids_view"]=array("-99"); @H_301_3@$data["readpoint"]=""; @H_301_3@$data["prefix"]=""; @H_301_3@$data["template"]="show"; @H_301_3@$data["status"]=99; @H_301_3@$data["updatetime"]=$time_tmp; @H_301_3@$contentid=$c->add($data,"",1); @H_301_3@@H_301_3@//添加评论 @H_301_3@$res=MysqL_query("select * from supe_spacecomments where itemid=$row[itemid] and rates=0",$conn1); @H_301_3@$comment_num=0; @H_301_3@while($rs=MysqL_fetch_array($res)){ @H_301_3@$comment["keyid"]="PHPcms-content-title-".$contentid; @H_301_3@if($rs["authorid"]==0){ @H_301_3@$comment["username"]="游客"; @H_301_3@$comment["userid"]=0; @H_301_3@}else{ @H_301_3@$comment["username"]=addslashes($rs["author"]); @H_301_3@$hasuser=hasuser($rs["author"]); @H_301_3@if($hasuser==0){ @H_301_3@$userinfo["username"]=addslashes($rs["author"]); @H_301_3@$userinfo["password"]="82790085228cf8a1e3bac41f45271e5f"; @H_301_3@$userinfo["touserid"]=$rs["authorid"]; @H_301_3@$userinfo["email"]=""; @H_301_3@$comment["userid"]=adduser($userinfo); @H_301_3@}else{ @H_301_3@$comment["userid"]=$hasuser; @H_301_3@} @H_301_3@@H_301_3@} @H_301_3@$comment["content"]=$rs["message"]; @H_301_3@$comment["ip"]=$rs["ip"]; @H_301_3@$comment["addtime"]=$rs["dateline"]; @H_301_3@if(MysqL_query("insert into PHPcms_comment(keyid,userid,username,content,ip,addtime,status) values('$comment[keyid]',$comment[userid],'$comment[username]','$comment[content]','$comment[ip]',$comment[addtime],1)",$conn2)){ @H_301_3@$comment_num+=1; @H_301_3@} @H_301_3@} @H_301_3@MysqL_query("update PHPcms_content_count set comments=$comment_num,comments_checked=$comment_num where contentid=$contentid"); @H_301_3@} @H_301_3@function dump($vars,$label = '',$return = false) @H_301_3@{ @H_301_3@if (ini_get('html_errors')) { @H_301_3@$content = "<pre>"; @H_301_3@if ($label != '') { @H_301_3@$content .= "<b>{$label} :</b>"; @H_301_3@} @H_301_3@$content .= htmlspecialchars(print_r($vars,true)); @H_301_3@$content .= "</pre>"; @H_301_3@} else { @H_301_3@$content = $label . " :" . print_r($vars,true); @H_301_3@} @H_301_3@if ($return) { return $content; } @H_301_3@echo $content; @H_301_3@return null; @H_301_3@} @H_301_3@/* @H_301_3@向PHPcms中添加用户 @H_301_3@*/ @H_301_3@function adduser($userinfo){ @H_301_3@global $conn2; @H_301_3@MysqL_query("insert into PHPcms_member(username,password,groupid,touserid,email) values('$userinfo[username]','$userinfo[password]',6,$userinfo[touserid],'$userinfo[email]')",$conn2); @H_301_3@$userid=MysqL_insert_id(); @H_301_3@MysqL_query("insert into PHPcms_member_cache(username,$conn2); @H_301_3@return $userid; @H_301_3@} @H_301_3@/* @H_301_3@判断PHPcms中是否有此用户 @H_301_3@*/ @H_301_3@function hasuser($username) @H_301_3@{ @H_301_3@global $conn2; @H_301_3@$res=MysqL_query("select userid from PHPcms_member where username='".$username."'",$conn2); @H_301_3@$row=MysqL_fetch_array($res); @H_301_3@if($row[0]){ @H_301_3@//有用户 @H_301_3@return $row[0]; @H_301_3@}else{ @H_301_3@//没用户 @H_301_3@return 0; @H_301_3@} @H_301_3@} @H_301_3@?>

需要的可以试用一下

完成了如下功能: @H_301_3@1、文章导入 @H_301_3@2、评论导入 @H_301_3@3、关键字导入 @H_301_3@4、如果supesite中某个用户做了评论,则在PHPcms中建立相应的帐号,并将评论和其绑定 @H_301_3@@H_301_3@使用方法: @H_301_3@1、因为没有导入分类,要在PHPcms中手动建立同名分类,因为管理是根据分类名称关联的 @H_301_3@2、修改conn1和conn2数据库地址、库名、用户、密码 @H_301_3@3、将代码存为conv.PHP,放到PHPcms根目录的 temp 文件夹中 @H_301_3@4、以管理员身份登录PHPcms @H_301_3@5、浏览器中运行localhost/temp/conv.PHP @H_301_3@@H_301_3@需要说明的是: @H_301_3@1、数据库连接要改成自己的 @H_301_3@2、代码中有些目录结构,表名要注意,可能你的环境和我的不一样 @H_301_3@3、当运行conv.PHP?action=clean的时候,可以清空PHPcms中的文章评论、关键字等数据 @H_301_3@4、function dump可以用更美观的形式打印array数组,用以调试 @H_301_3@5、附件手动复制到相应的目录下就可以了,按supesite的结构复制过来attachments/*** @H_301_3@6、因为我的PHPcms是和ucenter整合的,所以导过来的用户PHPcms中,密码是什么无所谓的,以后的注册登录验证都是走ucenter那边 @H_301_3@7、只导入了supesite中已发表的文章,未审核通过和垃圾箱的都没有导入。评论也是只有审核过的

猜你在找的Dedecms相关文章