动易数据转成dedecms的php程序

前端之家收集整理的这篇文章主要介绍了动易数据转成dedecms的php程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

PS:这个可以举一反三,如新云或NB等asp文章系统都可转为Dedecms或其它PHP的cms
<div class="codetitle"><a style="CURSOR: pointer" data="58182" class="copybut" id="copybut58182" onclick="doCopy('code58182')"> 代码如下:

<div class="codebody" id="code58182">
<?PHP
//读取mdb数据库例程
set_time_limit(0);
$conn=newcom("ADODB.Connection");
$connstr="DRIVER={MicrosoftAccessDriver(.mdb)};DBQ=".realpath("E:\web2\qq.mdb");
$conn->Open($connstr);
$rs=newcom("ADODB.RecordSet");
$rs->Open("select
fromPE_ArticleWhereArticleID>0orDERBYArticleIDASC",$conn,1,1); $conn2=MysqL_connect("localhost","root","");
MysqL_select_db("dede",$conn2);
MysqL_query("SETNAMESGBK",$conn2);
$i=0;
while(!$rs->eof){
$id=$rs->Fields('ArticleID')->value;
$title=addslashes($rs->Fields('Title')->value);
$classid=$rs->Fields('ClassID')->value;
$keywordstr=$rs->Fields('Keyword')->value;
$keywordstr=str_replace("|","",$keywordstr);
$keyword=trim($keywordstr);
$datestr=$rs->Fields('UpdateTime')->value;
$datearr=explode("-",$datestr);
$yy=$datearr[0];
$mm=$datearr[1];
$dd=rand(1,28);
$time=mktime(0,$mm,$dd,$yy);
$content=addslashes($rs->Fields('Content')->value);
$content=str_replace('[InstallDir_ChannelDir]{$UploadDir}','/UploadFiles',$content);
//$uploadfile=$rs->Fields('UploadFiles')->value;
$sql0="selectIDfromdede_archiveswhereID='$id'";
$rs0=MysqL_query($sql0,$conn2);
$row=MysqL_fetch_array($rs0);
if(intval($row['ID'])==0){
$sql1="insertintodede_archives(ID,typeid,channel,title,sortrank,pubdate,senddate,adminID,keywords)values('$id','$classid','$title','$time','$keyword')";
$rs1=MysqL_query($sql1,$conn2);
if(!$rs1){
echo$sql1;
echo"
";
echoMysqL_error();
echo"
";
//exit;
}
$id2=MysqL_insert_id();
if($id2>0){ $sql2="insertintodede_addonarticle(aid,body)values('$id','$content');";
$rs2=MysqL_query($sql2,$conn2);
if(!$rs2){
echo$sql2;
echo"
";
echoMysqL_error();
echo"
";
//exit;
}
}
}
$rs->MoveNext();
$i++;
if($i%50==0)sleep(5);
}
echo"完成";
?>

原文链接:https://www.f2er.com/php/29923.html

猜你在找的PHP相关文章