多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > php開(kāi)源 > DedeCMS > Supesite7.0 轉(zhuǎn)換導(dǎo)入phpcms 2008 sp3的方法

Supesite7.0 轉(zhuǎn)換導(dǎo)入phpcms 2008 sp3的方法

來(lái)源:程序員人生   發(fā)布時(shí)間:2014-02-17 19:57:37 閱讀次數(shù):4131次

前些天,寫(xiě)了一個(gè)php腳本用于supesite7.0導(dǎo)入phpcms2008:

<?php
/*
supesite7.0導(dǎo)入phpcms 2008 sp3 導(dǎo)入腳本
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';
//數(shù)據(jù)庫(kù)連接
//conn1為supesite數(shù)據(jù)庫(kù)
//conn2為phpcms數(shù)據(jù)庫(kù)
$conn1=mysql_connect("localhost","root","");
mysql_select_db("site",$conn1);
$conn2=mysql_connect("localhost","root","");
mysql_select_db("phpcms",$conn2);
//清空phpcms 文章和評(píng)論數(shù)據(jù)
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();
}
//讀取分類(lèi)表
$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自帶的類(lèi),添加內(nèi)容
$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);

//添加評(píng)論
$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中添加用戶(hù)
*/
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,password,groupid,touserid,email) values('$userinfo[username]','$userinfo[password]',6,$userinfo[touserid],'$userinfo[email]')",$conn2);
return $userid;
}
/*
判斷phpcms中是否有此用戶(hù)
*/
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]){
//有用戶(hù)
return $row[0];
}else{
//沒(méi)用戶(hù)
return 0;
}
}
?>

需要的可以試用一下

完成了如下功能:
1、文章導(dǎo)入
2、評(píng)論導(dǎo)入
3、關(guān)鍵字導(dǎo)入
4、如果supesite中某個(gè)用戶(hù)做了評(píng)論,則在phpcms中建立相應(yīng)的帳號(hào),并將評(píng)論和其綁定

使用方法:
1、因?yàn)闆](méi)有導(dǎo)入分類(lèi),要在phpcms中手動(dòng)建立同名分類(lèi),因?yàn)楣芾硎歉鶕?jù)分類(lèi)名稱(chēng)關(guān)聯(lián)的
2、修改conn1和conn2數(shù)據(jù)庫(kù)地址、庫(kù)名、用戶(hù)、密碼
3、將代碼存為conv.php,放到phpcms根目錄的 temp 文件夾中
4、以管理員身份登錄phpcms
5、瀏覽器中運(yùn)行l(wèi)ocalhost/temp/conv.php

需要說(shuō)明的是:
1、數(shù)據(jù)庫(kù)連接要改成自己的
2、代碼中有些目錄結(jié)構(gòu),表名要注意,可能你的環(huán)境和我的不一樣
3、當(dāng)運(yùn)行conv.php?action=clean的時(shí)候,可以清空phpcms中的文章、評(píng)論、關(guān)鍵字等數(shù)據(jù)
4、function dump可以用更美觀的形式打印array數(shù)組,用以調(diào)試
5、附件手動(dòng)復(fù)制到相應(yīng)的目錄下就可以了,按supesite的結(jié)構(gòu)復(fù)制過(guò)來(lái)attachments/***
6、因?yàn)槲业膒hpcms是和ucenter整合的,所以導(dǎo)過(guò)來(lái)的用戶(hù)在phpcms中,密碼是什么無(wú)所謂的,以后的注冊(cè)和登錄驗(yàn)證都是走ucenter那邊
7、只導(dǎo)入了supesite中已發(fā)表的文章,未審核通過(guò)和垃圾箱的都沒(méi)有導(dǎo)入。評(píng)論也是只有審核過(guò)的

生活不易,碼農(nóng)辛苦
如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 国内精品久久影视免费 | 性欧美free| 欧美夜色| 精品福利一区二区三区免费视频 | 亚洲综合图片人成综合网 | 天堂tv亚洲tv日本tv不卡 | 91精品一区二区三区在线 | 精品一区二区三区四区在线 | 亚洲乱码一二三四五六区 | 成人淫片免费视频95视频 | 秋霞理论一级在线观看手机版 | 精品影视网站入口 | 99热自拍 | 成人gav| 亚洲色图视频在线 | 美国一级毛片oo | 欧美成人综合视频 | 国产九九视频在线观看 | 国产一级毛片欧美视频 | 国内精品视频在线观看 | 淫欧美| www.色午夜 | 国产xxx护士爽免费看 | 国产伊人影院 | 欧美人欧美人与动人物性行为 | 欧美一级毛片无遮 | 亚洲欧美日韩国产色另类 | 国产日韩欧美一区二区三区在线 | 久久青娱乐 | 久久久久久国产精品三级 | 校园春色欧美色图 | 大杳蕉伊人狼人久久一本线 | 性欧美24videos | 福利午夜 | 97精品一区二区三区在线不卡 | 亚洲国产日韩综合久久精品 | 国产aaa级一级毛片 国产aaa免费视频国产 | 国产欧美日韩精品一区二 | 色综合美国色农夫网 | 噜噜噜久久 | 欧美一区二区在线播放 |