WordPress: Importing From Roller:修订间差异
(新页面: You can fairly easily import data from Roller using the MovableType import script. # Export your blog from the Roller database for importing into WordPress. # Copy photographs, images,...) |
无编辑摘要 |
||
第1行: | 第1行: | ||
You can fairly easily import data from Roller using the MovableType import script. | You can fairly easily import data from Roller using the MovableType import script. | ||
使用MovableType导入脚本,你能够轻易地从Roller中导入数据。 | |||
# Export your blog from the Roller database for importing into WordPress. | # Export your blog from the Roller database for importing into WordPress. | ||
#将你的博客从Roller数据库中导出,以便导入进WordPress。 | |||
# Copy photographs, images, graphics, video, and all content files to the appropriate directories in your WordPress site server. | # Copy photographs, images, graphics, video, and all content files to the appropriate directories in your WordPress site server. | ||
#将图片,图像,图像,视屏,以及所有的内容文件复制到你的WordPress站点服务器上适当的目录中。 | |||
# Modify the <code>$user</code>, <code>$oldresources</code>, <code>$newresources</code>, and <code>$connection</code> variables in the beginning of the script below script and place it on your server where PHP execution is allowed. | # Modify the <code>$user</code>, <code>$oldresources</code>, <code>$newresources</code>, and <code>$connection</code> variables in the beginning of the script below script and place it on your server where PHP execution is allowed. | ||
#更改脚本的开头,脚本下面的<code>$user</code>, <code>$oldresources</code>, <code>$newresources</code>, 和<code>$connection</code>变数,并且将变数放置到你的服务器上运行PHP的位置。 | |||
# Execute the script. This will create a "dump" of your Roller blog content into a MovableType Import format. | # Execute the script. This will create a "dump" of your Roller blog content into a MovableType Import format. | ||
#运行脚本,会将你的Roller博客的"大多内容"转变为MovableType导入格式。 | |||
# Use <code>wget</code> to store it into file. | # Use <code>wget</code> to store it into file. | ||
#使用<code>wget</code>,将这个格式储存到文件中。 | |||
Then follow the instructions for [[WordPress:Importing_from_Movable_Type_to_WordPress|Importing from Movable Type to WordPress]]. | Then follow the instructions for [[WordPress:Importing_from_Movable_Type_to_WordPress|Importing from Movable Type to WordPress]]. | ||
然后遵循[[WordPress:Importing_from_Movable_Type_to_WordPress|从Movable Type导入 WordPress]]的指示说明。 | |||
The following scripts should work for Roller pre-2.0 release. After Version 2.0, the comment table is changed to <code>roller_comment</code>. Change the select statement to <code>roller_comment</code>. | The following scripts should work for Roller pre-2.0 release. After Version 2.0, the comment table is changed to <code>roller_comment</code>. Change the select statement to <code>roller_comment</code>. | ||
下面的脚本应该适用于2.0版本之前的Roller。2.0版本之后,评论表格更改为<code>roller_comment</code>。将挑选的声明更改为<code>roller_comment</code>。 | |||
==Exporting Roller Database from postgresql== | ==Exporting Roller Database from postgresql== | ||
==从 postgresql中导出Roller数据库== | |||
For Roller using the postgresql database, copy the following script carefully and place it in a [[WordPress:Editing_Files|text editor]] and save it with an appropriate name as a PHP file. Upload it per the instructions above to your Roller server. | For Roller using the postgresql database, copy the following script carefully and place it in a [[WordPress:Editing_Files|text editor]] and save it with an appropriate name as a PHP file. Upload it per the instructions above to your Roller server. | ||
因为Roller使用postgresql数据库,仔细地复制下面的脚本,并且将叫脚本放置到[[WordPress:Editing_Files|文本编辑器]],用适当的名称将脚本保存为PHP文件。根据上述的指示将脚本上传到你的Roller服务器中。 | |||
<pre> | <pre> | ||
<html> | <html> | ||
第106行: | 第129行: | ||
</html> | </html> | ||
</pre> | </pre> | ||
<pre> | |||
<html> | |||
<head> | |||
<title>Roller 导出</title> | |||
</head> | |||
<body> | |||
<? | |||
// 假定Roller在postgresql上运行 | |||
//同时假定用户只有一个博客 | |||
// Roller使用的字符集是utf8,但这似乎至少是匹配的 | |||
// WordPress 一切正常,因此不要转变 | |||
// 只要更改脚本,将脚本储存在运行php的位置 | |||
// 以及wget the url | |||
// | |||
// Madis Kaal 提供 | |||
// | |||
$user = "bloguser"; | |||
// 在文章主体部分, $oldresources 所有的occurrencies | |||
// 由 $newresources代替 | |||
$oldresources = "/resources/bloguser/"; | |||
$newresources = "http://somesite/wp-content/"; | |||
// 在这里定义你的数据库连接 | |||
// dbname 是数据库的名称 | |||
//一般,位于本地主机 | |||
// 密码是用来访问db | |||
//用户是数据库的用户名 | |||
$connection = pg_connect("dbname=dbname host=localhost password=dbpassword user=dbuser"); | |||
// -- 就这么大,下面不需要做任何更改了------------------------------- | |||
// 得到用户ID | |||
$result = pg_Exec($connection, "select id from rolleruser where username='".$user."'"); | |||
$uid=pg_result($result,0,0); | |||
// 得到站点ID | |||
$result = pg_Exec($connection,"select id from website where userid='".$uid."'"); | |||
$siteid=pg_result($result,0,0); | |||
//得到这个站点的所有文章 | |||
$entries= pg_Exec($connection,"select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); | |||
// dump all entries | |||
echo "--------\n"; | |||
for($i=0; $i<(pg_numrows($entries)); $i++) | |||
{ | |||
// 将类别ID转变为类别名,我知道SQL-heads | |||
//只在查询中执行类别名,但是我是个完整的complete C-head | |||
$resultRow = pg_fetch_array($entries, $i); | |||
$c=$resultRow["categoryid"]; | |||
$cat=pg_result(pg_Exec($connection,"select name from weblogcategory where id='".$c."'"),0,0); | |||
// dump metadata first | |||
echo "PRIMARY CATEGORY: ".$cat."\n"; | |||
echo "AUTHOR: ".$user."\n"; | |||
echo "TITLE: ".$resultRow["title"]."\n"; | |||
$c=$resultRow["pubtime"]; | |||
// 将YYYY-MM-DD hh:mm:ss.ms转变为MM/DD/YYYY hh:mm:ss | |||
echo "日期: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; | |||
$c=$resultRow["publishentry"]; | |||
if ($c=="t") { $c="1"; } else { $c="0"; }; | |||
echo "STATUS: ".$c."\n"; | |||
$c=$resultRow["allowcomments"]; | |||
if ($c=="t") { $c="1"; } else { $c="0"; }; | |||
echo "ALLOW COMMENTS: ".$c."\n"; | |||
echo "-----\n"; | |||
// done with metadata, multiline entries follow | |||
echo "BODY:\n"; | |||
$c=str_replace($oldresources,$newresources,$resultRow["text"]); | |||
echo $c."\n"; | |||
// 找到文章的评论 | |||
$comments=pg_Exec("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); | |||
for ($j=0; $j<(pg_numrows($comments)); $j++) | |||
{ | |||
$c=pg_fetch_array($comments,$j); | |||
// 忽视所有包含url的评论。这样除去了垃圾广告以及 | |||
// 一些合法的评论 | |||
if (strpos($c["content"],"http://")===false) | |||
{ | |||
echo "-----\n"; | |||
echo "COMMENT:\n"; | |||
echo "AUTHOR: ".$c["name"]."\n"; | |||
echo "EMAIL: ".$c["email"]."\n"; | |||
echo "URL: ".$c["url"]."\n"; | |||
echo "IP: ".$c["remotehost"]."\n"; | |||
$d=$c["posttime"]; | |||
echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; | |||
echo $c["content"]."\n"; | |||
} | |||
} | |||
echo "--------\n"; | |||
} | |||
pg_close($connection); | |||
?> | |||
</body> | |||
</html> | |||
</pre> | |||
==Exporting Roller Database from MySQL== | ==Exporting Roller Database from MySQL== | ||
==从MySQL中导出Roller数据库== | |||
For MySQL databases, copy the following script carefully and place it in a [[WordPress:Editing_Files|text editor]] and save it with an appropriate name as a PHP file. Upload it per the instructions above to your Roller server. | For MySQL databases, copy the following script carefully and place it in a [[WordPress:Editing_Files|text editor]] and save it with an appropriate name as a PHP file. Upload it per the instructions above to your Roller server. | ||
对于MySQL数据库,仔细地复制下面的脚本,并且将这个脚本放置到[[WordPress:Editing_Files|文本编辑器]]并且适用适当的名称,将脚本作为PHP文件保存。根据上述的指示,将脚本上传到你的Roller服务器。 | |||
<pre> | <pre> | ||
第187行: | 第332行: | ||
// discard all comments containing url. this gets rid of spam, and also | // discard all comments containing url. this gets rid of spam, and also | ||
// some legimate comments as well | // some legimate comments as well | ||
if (strpos($c["content"],"http://")===false) | |||
{ | |||
echo "-----\n"; | |||
echo "COMMENT:\n"; | |||
echo "AUTHOR: ".$c["name"]."\n"; | |||
echo "EMAIL: ".$c["email"]."\n"; | |||
echo "URL: ".$c["url"]."\n"; | |||
echo "IP: ".$c["remotehost"]."\n"; | |||
$d=$c["posttime"]; | |||
echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; | |||
echo $c["content"]."\n"; | |||
} | |||
} | |||
echo "--------\n"; | |||
} | |||
mysql_close(); | |||
?> | |||
</body> | |||
</html> | |||
</pre> | |||
<pre> | |||
<html> | |||
<head> | |||
<title>Roller export</title> | |||
</head> | |||
<body> | |||
<? | |||
// 假定Roller在MySQL上运行 | |||
// 假定用户只有一个博客 | |||
// Roller使用的字符集是utf8,但是似乎至少匹配 | |||
// WordPress一切顺利,不需要转变 | |||
//只要更改脚本,将脚本储存在能够运行php的位置 | |||
// 和 wget the url | |||
// | |||
// Madis Kaal mast@nomad.ee提供 | |||
// | |||
$user = "yourusernameonroller"; | |||
// 在文章主体部分, $oldresources的所有的occurrencies | |||
// 由 $newresources取代 | |||
$oldresources = "/roller/page/username/"; | |||
$newresources = "/roller/page/username/"; | |||
// 在这里定义你的数据库连接 | |||
// dbname 是数据库名 | |||
// 通常,位于本地主机 | |||
// 密码用来访问数据库 | |||
//用户是数据库用户名 | |||
$username = "dbusername"; | |||
$password = "dbpassword"; | |||
$hostname = "localhost"; | |||
$dbname = "roller"; | |||
$dbh = mysql_connect($hostname, $username, $password); | |||
$connection = mysql_select_db($dbname,$dbh); | |||
// -- 就这么大,下面不需要任何变化了 | |||
------------------------------- | |||
// 得到用户ID | |||
$result = mysql_query("select id from rolleruser where username='".$user."'"); | |||
$uid=mysql_result($result,0,0); | |||
// 得到站点ID | |||
$result = mysql_query("select id from website where userid='".$uid."'"); | |||
$siteid=mysql_result($result,0,0); | |||
// 得到这个站点的所有文章 | |||
$entries= mysql_query("select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); | |||
// dump all entries | |||
echo "--------\n"; | |||
for($i=0; $i<(mysql_num_rows($entries)); $i++) | |||
{ | |||
// 将类别ID转变为类别名,我知道SQL-heads | |||
//只在查询中转变类别ID,但是我是个完成的complete C-head | |||
$resultRow = mysql_fetch_array($entries); | |||
$c=$resultRow["categoryid"]; | |||
$cat=mysql_result(mysql_query("select name from weblogcategory where id='".$c."'"),0,0); | |||
// dump metadata first | |||
echo "PRIMARY CATEGORY: ".$cat."\n"; | |||
echo "AUTHOR: ".$user."\n"; | |||
echo "TITLE: ".$resultRow["title"]."\n"; | |||
$c=$resultRow["pubtime"]; | |||
// 将YYYY-MM-DD hh:mm:ss.ms转变为 MM/DD/YYYY hh:mm:ss | |||
echo "日期: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; | |||
$c=$resultRow["publishentry"]; | |||
if ($c=="t") { $c="1"; } else { $c="0"; }; | |||
echo "STATUS: ".$c."\n"; | |||
$c=$resultRow["allowcomments"]; | |||
if ($c=="t") { $c="1"; } else { $c="0"; }; | |||
echo "ALLOW COMMENTS: ".$c."\n"; | |||
echo "-----\n"; | |||
// done with metadata, multiline entries follow | |||
echo "BODY:\n"; | |||
$c=str_replace($oldresources,$newresources,$resultRow["text"]); | |||
echo $c."\n"; | |||
// 找到文章的评论 | |||
$comments=mysql_query("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); | |||
for ($j=0; $j<(mysql_num_rows($comments)); $j++) | |||
{ | |||
$c=mysql_fetch_array($comments); | |||
// 忽视所有包含url的评论。这样会去除垃圾广告,和 | |||
// 一些合法的评论 | |||
if (strpos($c["content"],"http://")===false) | if (strpos($c["content"],"http://")===false) | ||
{ | { |
2008年9月8日 (一) 10:58的最新版本
You can fairly easily import data from Roller using the MovableType import script.
使用MovableType导入脚本,你能够轻易地从Roller中导入数据。
- Export your blog from the Roller database for importing into WordPress.
- 将你的博客从Roller数据库中导出,以便导入进WordPress。
- Copy photographs, images, graphics, video, and all content files to the appropriate directories in your WordPress site server.
- 将图片,图像,图像,视屏,以及所有的内容文件复制到你的WordPress站点服务器上适当的目录中。
- Modify the
$user
,$oldresources
,$newresources
, and$connection
variables in the beginning of the script below script and place it on your server where PHP execution is allowed.
- 更改脚本的开头,脚本下面的
$user
,$oldresources
,$newresources
, 和$connection
变数,并且将变数放置到你的服务器上运行PHP的位置。
- Execute the script. This will create a "dump" of your Roller blog content into a MovableType Import format.
- 运行脚本,会将你的Roller博客的"大多内容"转变为MovableType导入格式。
- Use
wget
to store it into file.
- 使用
wget
,将这个格式储存到文件中。
Then follow the instructions for Importing from Movable Type to WordPress.
然后遵循从Movable Type导入 WordPress的指示说明。
The following scripts should work for Roller pre-2.0 release. After Version 2.0, the comment table is changed to roller_comment
. Change the select statement to roller_comment
.
下面的脚本应该适用于2.0版本之前的Roller。2.0版本之后,评论表格更改为roller_comment
。将挑选的声明更改为roller_comment
。
Exporting Roller Database from postgresql[ ]
从 postgresql中导出Roller数据库[ ]
For Roller using the postgresql database, copy the following script carefully and place it in a text editor and save it with an appropriate name as a PHP file. Upload it per the instructions above to your Roller server.
因为Roller使用postgresql数据库,仔细地复制下面的脚本,并且将叫脚本放置到文本编辑器,用适当的名称将脚本保存为PHP文件。根据上述的指示将脚本上传到你的Roller服务器中。
<html> <head> <title>Roller export</title> </head> <body> <? // assumes that Roller is running on postgresql // it also assumes that there is only one blog for user // the character set used by Roller is utf8, but this seems to suit at least // WordPress just fine, so no conversions done // just modify the script, store it somewhere where php execution is allowed // and wget the url // // provided by Madis Kaal // $user = "bloguser"; // in entry body, all occurrencies of $oldresources are // replaced with $newresources $oldresources = "/resources/bloguser/"; $newresources = "http://somesite/wp-content/"; // define your database connection here // dbname is name of database // usually, it is on localhost // password is for accessing the db // and user is username for it $connection = pg_connect("dbname=dbname host=localhost password=dbpassword user=dbuser"); // -- this is it, no changes should be needed below ------------------------------- // get ID for user $result = pg_Exec($connection, "select id from rolleruser where username='".$user."'"); $uid=pg_result($result,0,0); // get ID for site $result = pg_Exec($connection,"select id from website where userid='".$uid."'"); $siteid=pg_result($result,0,0); // get all entries for this site $entries= pg_Exec($connection,"select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); // dump all entries echo "--------\n"; for($i=0; $i<(pg_numrows($entries)); $i++) { // turn the category ID into category name, I know SQL-heads would just // do it in query, but I'm a complete C-head $resultRow = pg_fetch_array($entries, $i); $c=$resultRow["categoryid"]; $cat=pg_result(pg_Exec($connection,"select name from weblogcategory where id='".$c."'"),0,0); // dump metadata first echo "PRIMARY CATEGORY: ".$cat."\n"; echo "AUTHOR: ".$user."\n"; echo "TITLE: ".$resultRow["title"]."\n"; $c=$resultRow["pubtime"]; // convert YYYY-MM-DD hh:mm:ss.ms to MM/DD/YYYY hh:mm:ss echo "DATE: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; $c=$resultRow["publishentry"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "STATUS: ".$c."\n"; $c=$resultRow["allowcomments"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "ALLOW COMMENTS: ".$c."\n"; echo "-----\n"; // done with metadata, multiline entries follow echo "BODY:\n"; $c=str_replace($oldresources,$newresources,$resultRow["text"]); echo $c."\n"; // find comments for the entry $comments=pg_Exec("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); for ($j=0; $j<(pg_numrows($comments)); $j++) { $c=pg_fetch_array($comments,$j); // discard all comments containing url. this gets rid of spam, and also // some legimate comments as well if (strpos($c["content"],"http://")===false) { echo "-----\n"; echo "COMMENT:\n"; echo "AUTHOR: ".$c["name"]."\n"; echo "EMAIL: ".$c["email"]."\n"; echo "URL: ".$c["url"]."\n"; echo "IP: ".$c["remotehost"]."\n"; $d=$c["posttime"]; echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; echo $c["content"]."\n"; } } echo "--------\n"; } pg_close($connection); ?> </body> </html>
<html> <head> <title>Roller 导出</title> </head> <body> <? // 假定Roller在postgresql上运行 //同时假定用户只有一个博客 // Roller使用的字符集是utf8,但这似乎至少是匹配的 // WordPress 一切正常,因此不要转变 // 只要更改脚本,将脚本储存在运行php的位置 // 以及wget the url // // Madis Kaal 提供 // $user = "bloguser"; // 在文章主体部分, $oldresources 所有的occurrencies // 由 $newresources代替 $oldresources = "/resources/bloguser/"; $newresources = "http://somesite/wp-content/"; // 在这里定义你的数据库连接 // dbname 是数据库的名称 //一般,位于本地主机 // 密码是用来访问db //用户是数据库的用户名 $connection = pg_connect("dbname=dbname host=localhost password=dbpassword user=dbuser"); // -- 就这么大,下面不需要做任何更改了------------------------------- // 得到用户ID $result = pg_Exec($connection, "select id from rolleruser where username='".$user."'"); $uid=pg_result($result,0,0); // 得到站点ID $result = pg_Exec($connection,"select id from website where userid='".$uid."'"); $siteid=pg_result($result,0,0); //得到这个站点的所有文章 $entries= pg_Exec($connection,"select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); // dump all entries echo "--------\n"; for($i=0; $i<(pg_numrows($entries)); $i++) { // 将类别ID转变为类别名,我知道SQL-heads //只在查询中执行类别名,但是我是个完整的complete C-head $resultRow = pg_fetch_array($entries, $i); $c=$resultRow["categoryid"]; $cat=pg_result(pg_Exec($connection,"select name from weblogcategory where id='".$c."'"),0,0); // dump metadata first echo "PRIMARY CATEGORY: ".$cat."\n"; echo "AUTHOR: ".$user."\n"; echo "TITLE: ".$resultRow["title"]."\n"; $c=$resultRow["pubtime"]; // 将YYYY-MM-DD hh:mm:ss.ms转变为MM/DD/YYYY hh:mm:ss echo "日期: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; $c=$resultRow["publishentry"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "STATUS: ".$c."\n"; $c=$resultRow["allowcomments"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "ALLOW COMMENTS: ".$c."\n"; echo "-----\n"; // done with metadata, multiline entries follow echo "BODY:\n"; $c=str_replace($oldresources,$newresources,$resultRow["text"]); echo $c."\n"; // 找到文章的评论 $comments=pg_Exec("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); for ($j=0; $j<(pg_numrows($comments)); $j++) { $c=pg_fetch_array($comments,$j); // 忽视所有包含url的评论。这样除去了垃圾广告以及 // 一些合法的评论 if (strpos($c["content"],"http://")===false) { echo "-----\n"; echo "COMMENT:\n"; echo "AUTHOR: ".$c["name"]."\n"; echo "EMAIL: ".$c["email"]."\n"; echo "URL: ".$c["url"]."\n"; echo "IP: ".$c["remotehost"]."\n"; $d=$c["posttime"]; echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; echo $c["content"]."\n"; } } echo "--------\n"; } pg_close($connection); ?> </body> </html>
Exporting Roller Database from MySQL[ ]
从MySQL中导出Roller数据库[ ]
For MySQL databases, copy the following script carefully and place it in a text editor and save it with an appropriate name as a PHP file. Upload it per the instructions above to your Roller server.
对于MySQL数据库,仔细地复制下面的脚本,并且将这个脚本放置到文本编辑器并且适用适当的名称,将脚本作为PHP文件保存。根据上述的指示,将脚本上传到你的Roller服务器。
<html> <head> <title>Roller export</title> </head> <body> <? // assumes that Roller is running on MySQL // it also assumes that there is only one blog for user // the character set used by Roller is utf8, but this seems to suit at least // WordPress just fine, so no conversions done // just modify the script, store it somewhere where php execution is allowed // and wget the url // // provided by Madis Kaal <mast@nomad.ee> // $user = "yourusernameonroller"; // in entry body, all occurrencies of $oldresources are // replaced with $newresources $oldresources = "/roller/page/username/"; $newresources = "/roller/page/username/"; // define your database connection here // dbname is name of database // usually, it is on localhost // password is for accessing the db // and user is username for it $username = "dbusername"; $password = "dbpassword"; $hostname = "localhost"; $dbname = "roller"; $dbh = mysql_connect($hostname, $username, $password); $connection = mysql_select_db($dbname,$dbh); // -- this is it, no changes should be needed below ------------------------------- // get ID for user $result = mysql_query("select id from rolleruser where username='".$user."'"); $uid=mysql_result($result,0,0); // get ID for site $result = mysql_query("select id from website where userid='".$uid."'"); $siteid=mysql_result($result,0,0); // get all entries for this site $entries= mysql_query("select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); // dump all entries echo "--------\n"; for($i=0; $i<(mysql_num_rows($entries)); $i++) { // turn the category ID into category name, I know SQL-heads would just // do it in query, but I'm a complete C-head $resultRow = mysql_fetch_array($entries); $c=$resultRow["categoryid"]; $cat=mysql_result(mysql_query("select name from weblogcategory where id='".$c."'"),0,0); // dump metadata first echo "PRIMARY CATEGORY: ".$cat."\n"; echo "AUTHOR: ".$user."\n"; echo "TITLE: ".$resultRow["title"]."\n"; $c=$resultRow["pubtime"]; // convert YYYY-MM-DD hh:mm:ss.ms to MM/DD/YYYY hh:mm:ss echo "DATE: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; $c=$resultRow["publishentry"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "STATUS: ".$c."\n"; $c=$resultRow["allowcomments"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "ALLOW COMMENTS: ".$c."\n"; echo "-----\n"; // done with metadata, multiline entries follow echo "BODY:\n"; $c=str_replace($oldresources,$newresources,$resultRow["text"]); echo $c."\n"; // find comments for the entry $comments=mysql_query("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); for ($j=0; $j<(mysql_num_rows($comments)); $j++) { $c=mysql_fetch_array($comments); // discard all comments containing url. this gets rid of spam, and also // some legimate comments as well if (strpos($c["content"],"http://")===false) { echo "-----\n"; echo "COMMENT:\n"; echo "AUTHOR: ".$c["name"]."\n"; echo "EMAIL: ".$c["email"]."\n"; echo "URL: ".$c["url"]."\n"; echo "IP: ".$c["remotehost"]."\n"; $d=$c["posttime"]; echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; echo $c["content"]."\n"; } } echo "--------\n"; } mysql_close(); ?> </body> </html>
<html> <head> <title>Roller export</title> </head> <body> <? // 假定Roller在MySQL上运行 // 假定用户只有一个博客 // Roller使用的字符集是utf8,但是似乎至少匹配 // WordPress一切顺利,不需要转变 //只要更改脚本,将脚本储存在能够运行php的位置 // 和 wget the url // // Madis Kaal mast@nomad.ee提供 // $user = "yourusernameonroller"; // 在文章主体部分, $oldresources的所有的occurrencies // 由 $newresources取代 $oldresources = "/roller/page/username/"; $newresources = "/roller/page/username/"; // 在这里定义你的数据库连接 // dbname 是数据库名 // 通常,位于本地主机 // 密码用来访问数据库 //用户是数据库用户名 $username = "dbusername"; $password = "dbpassword"; $hostname = "localhost"; $dbname = "roller"; $dbh = mysql_connect($hostname, $username, $password); $connection = mysql_select_db($dbname,$dbh); // -- 就这么大,下面不需要任何变化了 ------------------------------- // 得到用户ID $result = mysql_query("select id from rolleruser where username='".$user."'"); $uid=mysql_result($result,0,0); // 得到站点ID $result = mysql_query("select id from website where userid='".$uid."'"); $siteid=mysql_result($result,0,0); // 得到这个站点的所有文章 $entries= mysql_query("select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); // dump all entries echo "--------\n"; for($i=0; $i<(mysql_num_rows($entries)); $i++) { // 将类别ID转变为类别名,我知道SQL-heads //只在查询中转变类别ID,但是我是个完成的complete C-head $resultRow = mysql_fetch_array($entries); $c=$resultRow["categoryid"]; $cat=mysql_result(mysql_query("select name from weblogcategory where id='".$c."'"),0,0); // dump metadata first echo "PRIMARY CATEGORY: ".$cat."\n"; echo "AUTHOR: ".$user."\n"; echo "TITLE: ".$resultRow["title"]."\n"; $c=$resultRow["pubtime"]; // 将YYYY-MM-DD hh:mm:ss.ms转变为 MM/DD/YYYY hh:mm:ss echo "日期: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; $c=$resultRow["publishentry"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "STATUS: ".$c."\n"; $c=$resultRow["allowcomments"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "ALLOW COMMENTS: ".$c."\n"; echo "-----\n"; // done with metadata, multiline entries follow echo "BODY:\n"; $c=str_replace($oldresources,$newresources,$resultRow["text"]); echo $c."\n"; // 找到文章的评论 $comments=mysql_query("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); for ($j=0; $j<(mysql_num_rows($comments)); $j++) { $c=mysql_fetch_array($comments); // 忽视所有包含url的评论。这样会去除垃圾广告,和 // 一些合法的评论 if (strpos($c["content"],"http://")===false) { echo "-----\n"; echo "COMMENT:\n"; echo "AUTHOR: ".$c["name"]."\n"; echo "EMAIL: ".$c["email"]."\n"; echo "URL: ".$c["url"]."\n"; echo "IP: ".$c["remotehost"]."\n"; $d=$c["posttime"]; echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; echo $c["content"]."\n"; } } echo "--------\n"; } mysql_close(); ?> </body> </html>