Home > Backend Development > PHP Tutorial > PHP program that converts Dongyi data into dedecms_PHP tutorial

PHP program that converts Dongyi data into dedecms_PHP tutorial

WBOY
Release: 2016-07-21 15:55:43
Original
920 people have browsed it

PS: This can be used to draw inferences. ASP article systems such as Xinyun or NB can be converted to dedecms or other PHP cms

Copy code The code is as follows:

//读取mdb数据库例程  
set_time_limit(0); 
$conn = new com("ADODB.Connection");  
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("E:web2qq.mdb");  
$conn->Open($connstr);  
$rs = new com("ADODB.RecordSet");  
$rs->Open("select * from PE_Article Where ArticleID>0 orDER BY ArticleID ASC",$conn,1,1);  

$conn2 = mysql_connect("localhost","root",""); 
mysql_select_db("dede",$conn2); 
mysql_query("SET NAMES GBK",$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,0,0,$mm,$dd,$yy); 
    $content =addslashes($rs->Fields('Content')->value);  
    $content = str_replace('[InstallDir_ChannelDir]{$UploadDir}','/UploadFiles',$content); 

     
    //$uploadfile = $rs->Fields('UploadFiles')->value;  
    $sql0 = "select ID from dede_archives where ID='$id'"; 
    $rs0 = mysql_query($sql0,$conn2); 
    $row = mysql_fetch_array($rs0); 
    if(intval($row['ID'])==0){ 
        $sql1 = "insert into dede_archives (ID,typeid,channel,title,sortrank,pubdate,senddate,adminID,keywords) values ('$id','$classid',1,'$title','$time','$time','$time',1,'$keyword')"; 
        $rs1 = mysql_query($sql1,$conn2); 
        if(!$rs1){ 
            echo $sql1; 
            echo "
"; 
            echo mysql_error(); 
            echo "
"; 
            //exit; 
        } 
        $id2 = mysql_insert_id(); 
        if($id2>0){ 

            $sql2 = "insert into dede_addonarticle (aid ,typeid, body ) values('$id','$classid','$content');"; 
            $rs2 = mysql_query($sql2,$conn2); 
            if(!$rs2){ 
                echo $sql2; 
                echo "
"; 
                echo mysql_error(); 
                echo "
"; 
                //exit; 
            } 
        } 
    } 
    $rs->MoveNext();  
    $i++; 
    if($i%50==0)sleep(5); 
}  
echo "完成"; 
?> 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318202.htmlTechArticlePS:这个可以举一反三,如新云或NB等asp文章系统都可转为dedecms或其它php的cms 复制代码 代码如下: ?php //读取mdb数据库例程 set_time_limit(0); $...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template