|
Shared Hosting Free 50000 Disk Space 250000 bandwith Unlimited Features Rvskin Rv SiteBuilder Instant Activation |
- <?php
- /**
- * SABLOG-X v1.6 转 WordPress 2.6.5
- * author: Linvo
- * date: 2008-12-6
- * 注意:
- * 1、只转换日志和评论数据
- * 2、两者数据表在同一库中
- */
- header('Content-Type:text/html;Charset=utf-8;');
- date_default_timezone_set("PRC");
- $DBaddress = 'localhost'; //服务器
- $DBusername = 'root'; //mysql用户名
- $DBpassword = 'pwd'; //mysql密码
- $DBname = 'dbname'; //数据库名
- mysql_connect($DBaddress, $DBusername, $DBpassword);
- mysql_query('set names utf8');
- mysql_select_db($DBname);
- /*
- * 添加日志
- */
- $error = '';
- $sql_from = 'SELECT articleid,uid,dateline,content,title,description,comments
- FROM sablog_articles';
- $result = mysql_query($sql_from);
- while($item = mysql_fetch_row($result))
- {
- $item[2] = date('Y-m-d H:i:s', $item[2]);
- $item[3] = addslashes($item[3]);
- $item[5] = addslashes($item[5]);
- $sql_to = "INSERT INTO wp_posts(ID,post_author,post_date,post_content,
- post_title,post_excerpt,comment_count)
- VALUE('$item[0]','$item[1]','$item[2]','$item[3]','$item[4]','$item[5]','$item[6]')";
- mysql_query($sql_to);
- if(mysql_affected_rows() != 1) $error .= "日志转换出错,出错ID:$item[0] <br />";
- }
- if(emptyempty($error)) echo '日志转换完毕!<br />';
- else echo $error;
- /*
- * 添加评论
- */
- $error = '';
- $sql_from = 'SELECT commentid,articleid,author,url,ipaddress,dateline,content
- FROM sablog_comments';
- $result = mysql_query($sql_from);
- while($item = mysql_fetch_row($result))
- {
- $item[5] = date('Y-m-d H:i:s', $item[5]);
- $item[6] = addslashes($item[6]);
- $sql_to = "INSERT INTO wp_comments(comment_ID,comment_post_ID,comment_author,
- comment_author_url,comment_author_IP,comment_date,comment_content)
- VALUE('$item[0]','$item[1]','$item[2]','$item[3]','$item[4]','$item[5]','$item[6]')";
- mysql_query($sql_to);
- if(mysql_affected_rows() != 1) $error .= "评论转换出错,出错ID:$item[0] <br />";
- }
- if(emptyempty($error)) echo '评论转换完毕!<br />';
- else echo $error;
- ?>

Tags:



