加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

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

发布时间:2021-05-18 11:26:16 所属栏目:教程 来源:网络整理
导读:前些天,写了一个php脚本用于supesite7.0导入phpcms2008: ?php /* supesite7.0导入phpcms 2008 sp3 导入脚本 warran@qq.com http://www.veryhuo.com */ header(Content-Type: text/html;charset=utf-8); set_time_limit(0); define('IN_ADMIN',TRUE); defin
副标题[/!--empirenews.page--]

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

<?php
/*
supesite7.0导入phpcms 2008 sp3 导入脚本
warran@qq.com
http://www.veryhuo.com
*/
header("Content-Type: text/html;charset=utf-8");
set_time_limit(0);
define('IN_ADMIN',TRUE);
define('IN_PHPCMS',TRUE);
require_once '../include/common.inc.php';
require_once '../include/admin/process.class.php';
require '../include/priv_role.class.php';
require_once '../include/attachment.class.php';
require_once '../include/admin/content.class.php';
//数据库连接
//conn1为supesite数据库
//conn2为phpcms数据库
$conn1=mysql_connect("localhost","root","");
mysql_select_db("site",$conn1);
$conn2=mysql_connect("localhost","");
mysql_select_db("phpcms",$conn2);
//清空phpcms 文章和评论数据
if($_GET["action"]=='clean'){
mysql_query("delete from phpcms_content where 1=1",$conn2);
mysql_query("delete from phpcms_content_count where 1=1",$conn2);
mysql_query("delete from phpcms_c_news where 1=1",$conn2);
mysql_query("delete from phpcms_content_tag where 1=1",$conn2);
mysql_query("delete from phpcms_keyword where 1=1",$conn2);
mysql_query("delete from phpcms_member_group_priv where 1=1",$conn2);
mysql_query("delete from phpcms_comment where 1=1",$conn2);
exit("清空完成");
}
if($_GET["action"]=='test'){
echo hasuser("warran");
exit();
}
//读取分类表
$result=mysql_query("select catid,catname from phpcms_category",$conn2);
while($row=mysql_fetch_array($result)){
$cat["$row[catname]"]=$row[catid];
}
$_roleid = cache_read('admin_role_'.$_userid.'.php');
$priv_role = new priv_role();
$c = new content();
$tmp=0;
//添加文章
$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);
while($row=mysql_fetch_array($result)){
//使用phpcms自带的类,添加内容
$data["catid"]=$cat[$row["catname"]];
$attachment = new attachment("phpcms",$data["catid"]);
$data["title"]=addslashes($row["subject"]);
$data["style"]="";
$data["thumb"]="";
$res=mysql_query("select * from supe_spacenews where itemid=$row[itemid]",$conn1);
$includetags="";
$message="";
while($rs=mysql_fetch_array($res)){
$message.=$rs["message"];
if($rs["includetags"]!=''){
$includetags.=" ".$rs["includetags"];
}
}
$data["keywords"]=addslashes($includetags);
$data["author"]=addslashes($row["username"]);
$data["copyfrom"]=addslashes($row["newsauthor"]);
$data["description"]="";
$data["content"]=addslashes($message);
$data["paginationtype"]="0";
$data["maxcharperpage"]="10000";
$data["titleintact"]=addslashes($row["short_subject"]);
$data["islink"]="99";
$time_tmp=date("Y-m-d h:i:s");
$data["inputtime"]=$time_tmp;
$data["posids"]="-99";
$data["groupids_view"]=array("-99");
$data["readpoint"]="";
$data["prefix"]="";
$data["template"]="show";
$data["status"]=99;
$data["updatetime"]=$time_tmp;
$contentid=$c->add($data,"",1);

//添加评论
$res=mysql_query("select * from supe_spacecomments where itemid=$row[itemid] and rates=0",$conn1);
$comment_num=0;
while($rs=mysql_fetch_array($res)){
$comment["keyid"]="phpcms-content-title-".$contentid;
if($rs["authorid"]==0){
$comment["username"]="游客";
$comment["userid"]=0;
}else{
$comment["username"]=addslashes($rs["author"]);
$hasuser=hasuser($rs["author"]);
if($hasuser==0){
$userinfo["username"]=addslashes($rs["author"]);
$userinfo["password"]="82790085228cf8a1e3bac41f45271e5f";
$userinfo["touserid"]=$rs["authorid"];
$userinfo["email"]="";
$comment["userid"]=adduser($userinfo);
}else{
$comment["userid"]=$hasuser;
}

}
$comment["content"]=$rs["message"];
$comment["ip"]=$rs["ip"];
$comment["addtime"]=$rs["dateline"];
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)){
$comment_num+=1;
}
}
mysql_query("update phpcms_content_count set comments=$comment_num,comments_checked=$comment_num where contentid=$contentid");
}
function dump($vars,$label = '',$return = false)
{
if (ini_get('html_errors')) {
$content = "<pre>";
if ($label != '') {
$content .= "<b>{$label} :</b>";
}
$content .= htmlspecialchars(print_r($vars,true));
$content .= "</pre>";
} else {
$content = $label . " :" . print_r($vars,true);
}
if ($return) { return $content; }
echo $content;
return null;
}
/*
向phpcms中添加用户
*/
function adduser($userinfo){
global $conn2;
mysql_query("insert into phpcms_member(username,password,groupid,touserid,email) values('$userinfo[username]','$userinfo[password]',6,$userinfo[touserid],'$userinfo[email]')",$conn2);
$userid=mysql_insert_id();
mysql_query("insert into phpcms_member_cache(username,$conn2);
return $userid;
}
/*
判断phpcms中是否有此用户
*/
function hasuser($username)
{
global $conn2;
$res=mysql_query("select userid from phpcms_member where username='".$username."'",$conn2);
$row=mysql_fetch_array($res);
if($row[0]){
//有用户
return $row[0];
}else{
//没用户
return 0;
}
}
?>

需要的可以试用一下

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读