Johan Rylander

2010-02-01

Export from roller to wordpress

Postat i: Computers — Johan Rylander @ 22:33

The script at http://codex.wordpress.org/Importing_From_Roller did not work on my but the below did. Two things:

  1. The below script does not export the comments
  2. For importing to wordpress.com at least, the encoding should be UTF-8

<html>
<head>
<title>Roller export</title>
</head>   
<body>
<?php
// 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 = "johan";
// 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 = "rollerdb";
$password = "rollerdb";
$hostname = "localhost";
$dbname = "rollerdb";
$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++)
{
 $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";
 echo "--------\n";
}
?>
</body>
</html>

Kommentera »

Inga kommentarer ännu.

RSS-flöde för kommentarer till det här inlägget. TrackBack URI

Lämna en kommentar

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter-bild

You are commenting using your Twitter account. Logga ut / Ändra )

Facebook-foto

You are commenting using your Facebook account. Logga ut / Ändra )

Ansluter till %s

Tema: Silver is the New Black. Blogga med WordPress.com.

Follow

Get every new post delivered to your Inbox.