转移完成

花了两个小时把以前JRblog上的文章全转移到wordpress上来了。。。好久不写PHP再写起来真手生

不过现在总算有75篇文章了,哇哈哈,向100篇文章迈进!

为了撑点字数干脆把代码的主体发上来吧。。

  1. <?php
  2. /*
  3. boblog_blogs:
  4. blogid
  5. title
  6. pubtime
  7. content
  8.  
  9. wp_posts:
  10. ID
  11. post_author=2
  12. post_date:2007-05-03 22:29:27
  13. post_date_gmt:前者-8
  14. post_content
  15. post_title
  16. post_catagory=0
  17. post_status=publish
  18. comment_status=open
  19. ping_status=open
  20. post_name=post_title的encoded版
  21. post_modified=post_date
  22. post_modified_gmt=post_date_gmt
  23. guid=http://www.jerryhong.com/2007/05/19/post_name
  24. comment_count=0
  25. */
  26. include_once('jmysql.php');
  27. $result=db_query('select title, pubtime, content from boblog_blogs');
  28. foreach($result as $tuple)
  29. //$tuple=$result[0];
  30. {
  31. $post_date=date('Y-m-d h:i:s', $tuple[pubtime]);
  32. $post_name=addslashes(urlencode($tuple[title]));
  33. $guid="http://www.jerryhong.com/".date('Y',$tuple[pubtime]).'/'.date('m',$tuple[pubtime]).'/'.date('d',$tuple[pubtime]).'/'.$post_name;
  34. $tuple[content]=addslashes($tuple[content]);
  35. $tuple[title]=addslashes($tuple[title]);
  36.  
  37. $sql="INSERT INTO `wp_posts` ( `ID` , `post_author` , `post_date` , `post_date_gmt` , `post_content` , `post_title` , `post_category` , `post_excerpt` , `post_status` , `comment_status` , `ping_status` , `post_password` , `post_name` , `to_ping` , `pinged` , `post_modified` , `post_modified_gmt` , `post_content_filtered` , `post_parent` , `guid` , `menu_order` , `post_type` , `post_mime_type` , `comment_count` ) VALUES ( NULL , '2', '$post_date', '$post_date', '$tuple[content]', '$tuple[title]', '0', '', 'publish', 'open', 'open', '', '$post_name', '', '', '$post_date', '$post_date', '', '$guid', '', '0', 'post', '', '0')";
  38. echo ($sql);
  39. db_query($sql);
  40. }

Related posts

0 Responses to “转移完成”


  1. No Comments

Leave a Reply