Hongmu Notes
Home Program Notes WordPress Data Migration Empire – Article Migration Code
Program Notes Empire cms

WordPress Data Migration Empire – Article Migration Code

WordPress Data Migration Empire – Article Migration Code

Continuing from the code in the previous article; below is the code for redirecting the article:

 隐藏内容:会员可查看
<?php
require("./config.php");
$dbname2 = 'www_azhenxi_com';
$dbname = 'ecms_site';

$u = empty($_GET['n'])?0:$_GET['n'];

if(empty($_GET['n'])){
    turncate($dbname,'phome_ecms_news');
    turncate($dbname,'phome_ecms_news_check');
    turncate($dbname,'phome_ecms_news_check_data');
    turncate($dbname,'phome_ecms_news_data_1');
    turncate($dbname,'phome_ecms_news_index');
}

define('EmpireCMSAdmin','1');
require("../e/class/connect.php");

require("../e/class/db_sql.php");
require("../e/class/functions.php");
require("../e/class/delpath.php");

require("../e/class/copypath.php");
require("../e/class/t_functions.php");
require("../e/data/dbcache/class.php");
require("../e/data/dbcache/MemberLevel.php");

$link=db_connect();

$empire=new mysqlquery();

$r=$empire->query("SELECT * FROM `$dbname2`.`liwuposts` where  `post_type` = 'post' and `ID` > {$u} order by `ID` ASC limit 50");

$_POST = json_decode(file_get_contents("post.json"),true);
while($r2=$empire->fetch($r))        //循环获取查询记录
{
    
    $classid = $empire->query("SELECT * FROM `$dbname2`.`liwuterm_relationships` WHERE `object_id` = {$r2['ID']} ");
    $classid = $empire->fetch($classid);
    $classid = $classid['term_taxonomy_id'];
    
    // print_r($classid);die;
    // print_r($r2);die;
    
    $_POST['titlepic'] = '';
    $_POST['newstext'] = htmlspecialchars_decode($r2['post_content']);
    
    $_POST['newstext'] = preg_replace('/<img.*?>/i', '', $_POST['newstext']);
    $_POST['newstext'] = preg_replace('/<figure.*?>*?<\/figure>/i', '', $_POST['newstext']);

    // print_r($_POST['newstext']);
    $time = strtotime($r2['post_date']);
    
    
    $sql1 = "INSERT INTO `{$dbname}`.`phome_ecms_news` (`id`, `classid`, `ttid`, `onclick`, `plnum`, `totaldown`, `newspath`, `filename`, `userid`, `username`, `firsttitle`, `isgood`, `ispic`, `istop`, `isqf`, `ismember`, `isurl`, `truetime`, `lastdotime`, `havehtml`, `groupid`, `userfen`, `titlefont`, `titleurl`, `stb`, `fstb`, `restb`, `keyboard`, `title`, `newstime`, `titlepic`, `ftitle`, `smalltext`, `diggtop`) VALUES ({$r2['ID']}, '{$classid}', '0', '0', '0', '0', '', '1', '1', 'admin', '0', '0', '0', '0', '0', '0', '0', '{$time}', '{$time}', '1', '0', '0', '', '', '1', '1', '1', '{$r2['post_excerpt']}', '{$r2['post_title']}', '{$time}', '{$_POST['titlepic']}', '{$r2['post_title']}', '".addcslashes($r2['post_excerpt'])."', '0') ;";
    
    $sql2 = "INSERT INTO `{$dbname}`.`phome_ecms_news_data_1` (`id`, `classid`, `keyid`, `dokey`, `newstempid`, `closepl`, `haveaddfen`, `infotags`, `writer`, `befrom`, `newstext`) VALUES ({$r2['ID']}, '{$classid}', '', '1', '0', '0', '0', '', '心动礼物网', '心动礼物网', '".addslashes($_POST['newstext'])."') ;";
    
    
    $sql3 = "INSERT INTO `{$dbname}`.`phome_ecms_news_index` (`id`, `classid`, `checked`, `newstime`, `truetime`, `lastdotime`, `havehtml`) VALUES ({$r2['ID']}, '{$classid}', '1', '{$time}', '{$time}', '{$time}', '1') ;";
    
    if($empire->query($sql1)){
        echo "文章《{$r2['post_title']}》更新成功/33%<br>";
    }else{
        echo "文章《{$r2['post_title']}》更新失败/33%:{$sql1}<br>";
    }
    if($empire->query($sql2)){
        echo "文章《{$r2['post_title']}》更新成功/66%<br>";
    }else{
        echo "文章《{$r2['post_title']}》更新失败/66%:{$sql2}<br>";
    }
    if($empire->query($sql3)){
        echo "文章《{$r2['post_title']}》更新成功/100%<br><br>";
    }else{
        echo "文章《{$r2['post_title']}》更新失败/100%:{$sql3}<br>";
    }
    
    $u = $r2['ID'];
}
db_close();
$empire=null;

// die;
    $_GET['n'] = $u;
    $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?n=".$_GET['n'];
    echo '<html>';
    echo '<head>';
    echo '<meta http-equiv="refresh" content="0; url='.$url.'">';
    echo '</head>';

JSON file code:

{"ehash_bf9a":"7f4acc1ed062a816ee25","rhash_ce6d":"0d7212cbe5bd","ehash_4IIMJ":"Ccf04syPf3ocZwpV7k0w","ehash_d84b":"4cfed5520f59c446154c","rhash_Bgyf0":"macGrGq7mGD6","ehash_24e9":"0fd0b314591732e306fb","enews":"AddNews","classid":"1","bclassid":"0","id":"0","filepass":"1678417767","username":"","oldfilename":"","oldgroupid":"","oldchecked":"1","newstext_url":"","ecmsfrom":"http:\/\/ecms10260.yanshi.4s5.cn\/e\/admin\/ListNews.php?&ehash_4IIMJ=Ccf04syPf3ocZwpV7k0w&bclassid=0&classid=1","ecmsnfrom":"1","fstb":"","oldttid":"","ecmscheck":"0","ztids":"","zcids":"","oldztids":"","oldzcids":"","havetmpic":"0","title":"\u6807\u9898","titlecolor":"","ftitle":"\u526f\u6807\u9898","checked":"1","isgood":"0","firsttitle":"0","keyboard":"\u5173\u952e\u8bcd","titleurl":"","newstime":"2023-03-10 11:09:27","titlepic":"\u56fe\u7247","smalltext":"\u7b80\u4ecb","writer":"\u4f5c\u8005","w_id":"\u9009\u62e9\u4f5c\u8005","befrom":"\u65b0\u95fb\u6765\u6e90","befrom_id":"\u9009\u62e9\u4fe1\u606f\u6765\u6e90","newstext":"\u6b63\u6587","dokey":"1","qz_url":"","autosize":"5000","getfirsttitlepic":"","getfirsttitlespicw":"105","getfirsttitlespich":"118","istop":"0","newstempid":"0","groupid":"0","userfen":"0","onclick":"0","totaldown":"0","newspath":"","filename":"","infotags":"tag,tag2","oldinfotags":"","info_diyotherlink":"0","info_keyid":"","info_infouptime":"","info_infodowntime":"","vote_title":"","vote_name":["","","","","","","",""],"vote_num":["0","0","0","0","0","0","0","0"],"v_vote_num":"1","v_editnum":"8","vote_class":"0","dovote_ip":"0","vote_olddotime":"0000-00-00","vote_dotime":"0000-00-00","vote_width":"500","vote_height":"300","vote_tempid":"1","addnews":" \u63d0 \u4ea4 "}
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Empire CMS database statement & SQL statement format

Empire CMS database statement & SQL statement format Program Notes Empire cms

Introduction to Imperial CMS extended SQL program writing, basic examples of Imperial CMS database statements & SQL statement formats: Note: The following examples are based on placing PHP files in the system root directory. Example 1: Connect to MYSQL program. (a.php)<?php require('e/class/connect.php'); //Introduce database configuration files and public function files requ…
👁 351
Empire CMS obtains the system COOKIE variable function getcvar()

Empire CMS obtains the system COOKIE variable function getcvar() Program Notes Empire cms

Get the system COOKIE variable function syntax: getcvar($var,$ecms) Description: $var: is the variable name $ecms: 0 is to set the foreground COOKIE variable, 1 is to set the background COOKIE variable. This parameter can be omitted and defaults to 0. Usage example: getcvar('mlusername'), get the user name of the front-end login member getcvar('loginu...
👁 295
Empire CMS smart label call field collection

Empire CMS smart label call field collection Program Notes Empire cms

Collect and classify all fields that support smart tag calls into Empire CMS smart tags: [e:loop={column ID/topic ID, number of items displayed, operation type, only display pictures with titles, additional SQL conditions, display sorting}] Template code content [/e:loop] Calling time: <?=date('m-d',$bqr[newstime])?> <?=dat…
👁 3749

Recommended reading

Heavy Industry Machinery – Excavator Website Template 0663

Heavy Industry Machinery – Excavator Website Template 0663 Practical Collection Yiyou template

This EyouCMS template is designed for the heavy machinery and excavator industry, featuring a bold yellow design style ideal for showcasing excavator products, heavy-duty machinery equipment, technical specifications, and construction case studies. It enables heavy machinery enterprises to showcase their products online and attract mining and infrastructure clients. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS...
👁 49
(Adaptive mobile version) Bilingual (Chinese/English) website template; Electronic components & semiconductor chip website template – 1092

(Adaptive mobile version) Bilingual (Chinese/English) website template; Electronic components & semiconductor chip website template – 1092 Practical Collection pbootcms Template

A bilingual (Chinese/English) PbootCMS website template designed for electronic component and chip R&D enterprises, supporting both PC and WAP devices. Its modern, international design is ideal for showcasing products and technologies. The multilingual support facilitates effective brand promotion in global markets. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.c...
👁 42
(Adaptive mobile version) PBootCMS template for technology news and information websites; Download source code for financial news and information websites – 0371

(Adaptive mobile version) PBootCMS template for technology news and information websites; Download source code for financial news and information websites – 0371 Practical Collection pbootcms Template

This is an adaptive mobile-friendly technology news blog and financial news PbootCMS website template. It features a modern information-flow design, ideal for aggregating technology updates, financial news, and in-depth analyses. This template helps technology and finance media outlets attract online readers and build industry influence. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 48
sqlite uses PDO to execute SQL statements exec(), query()

sqlite uses PDO to execute SQL statements exec(), query() Language Notes mySql

In PHP scripts, executing SQL queries using PDO to interact with a database can be done through three different approaches; the choice of which method to use depends on the specific operation you intend to perform. 1. Using the PDO::exec() method: When executing queries such as INSERT, UPDATE, or DELETE that do not return a result set, use the exec() method on a PDO object to execute the query. Upon successful execution, this method returns the number of affected rows...
👁 323
Responsive Logistics System Equipment Website Template 0664

Responsive Logistics System Equipment Website Template 0664 Practical Collection Yiyou template

An eyouCMS responsive website template designed for the logistics system and equipment industry. Its professional, tech-oriented design is ideal for showcasing logistics systems, warehousing equipment, solutions, and project cases. This template helps logistics equipment companies present their products online and attract both e-commerce and logistics clients. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YououCMS...
👁 38
(Adaptive mobile version) Furniture & Home Textiles Website Template – Bedding Products Website Source Code Download – 1093

(Adaptive mobile version) Furniture & Home Textiles Website Template – Bedding Products Website Source Code Download – 1093 Practical Collection pbootcms Template

A PbootCMS website template for furniture, home textiles, and bedding products, compatible with both PC and WAP devices. Its cozy and practical design is ideal for showcasing home textile products, bedding items, and brand stories. This template helps home textile brands attract online customers and enhance their brand image. Template Preview | Installation Instructions | Website Admin Panel: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles: Pb...
👁 41