I imported about 130 user accounts and 100 stories from postnuke into serendipity the old fashioned way - I wrote a quick script that would generate the INSERT statements (our DB is MySQL). Since I needed to tweak the script repeatedly, I didn't want to have the script do the actual insert.
My Method:
1 - set up serendipity DB
2 - select all nuke_users and create insert statements into s9y quthors:
Code: Select all
<?php
/*
This is a quick an dirty script to import PostNuke 0.726 Phoenix users into Serendipity 0.7 authors
*/
// Enter Database info:
$dbname="Phoenix";
$user="dbname";
$password="dbpass";
$server="localhost";
$getPMUserSQL="select pn_uname, pn_uid, pn_pass, pn_email from nuke_users";
function dbconnect ($dbname,$user,$password,$server)
{
if (!($mylink = mysql_connect($server,$user,$password)))
{
print "<h3>could not connect to database</h3>\n";
exit;
}
mysql_select_db($dbname);
}
function safe_query ($query = "")
{
global $query_debug;
if (empty($query)) { return FALSE; }
if (!empty($query_debug)) { print "<pre>$query</pre>\n"; }
$result = mysql_query($query)
or die("ack! query failed: "
."<li>errorno=".mysql_errno()
."<li>error=".mysql_error()
."<li>query=".$query
);
return $result;
}
dbconnect($dbname,$user,$password,$server);
$useresult = safe_query($getPMUserSQL);
$users = array();
?>
<h2>Serendipity User SQL:</h2>
<pre>
<?
while ($myRow = mysql_fetch_array($useresult))
{
?>
INSERT INTO `serendipity_authors` VALUES ('<?= $myRow["pn_uname"] ?>', '<?= $myRow["pn_pass"] ?>', <?= $myRow["pn_uid"] ?>, 0, 0, '<?= $myRow["pn_email"] ?>', 0, 1);
<?
}
?>
</pre>
I did a similar thing to import postnuke stories into s9y as entries:
Code: Select all
<?php
/*
This is a quick an dirty script to import PostNuke 0.726 Phoenix stories into Serendipity 0.7 entries
*/
// Enter Database info:
$dbname="Phoenix";
$user="dbuser";
$password="dbpass";
$server="localhost";
$storysql="select pn_sid as id, pn_aid as authorid, pn_title as title, UNIX_TIMESTAMP(pn_time) as timestamp, pn_bodytext as extended, pn_hometext as body from nuke_stories" ;
function dbconnect ($dbname,$user,$password,$server)
{
if (!($mylink = mysql_connect($server,$user,$password)))
{
print "<h3>could not connect to database</h3>\n";
exit;
}
mysql_select_db($dbname);
}
function safe_query ($query = "")
{
global $query_debug;
if (empty($query)) { return FALSE; }
if (!empty($query_debug)) { print "<pre>$query</pre>\n"; }
$result = mysql_query($query)
or die("ack! query failed: "
."<li>errorno=".mysql_errno()
."<li>error=".mysql_error()
."<li>query=".$query
);
return $result;
}
dbconnect($dbname,$user,$password,$server);
$useresult = safe_query($storysql);
$users = array();
?>
<h2>Serendipity Entry SQL:</h2>
<pre>
<?
while ($myRow = mysql_fetch_array($useresult))
{
// do post processing conversions here -
// -- remove the <br /> tags pn puts in there:
$bodyStr = str_replace("<br />","",$myRow["body"]);
$extendedStr = str_replace("<br />","",$myRow["extended"]);
$exFlag = 0;
if ($extendedStr != "")
{
$exFlag = 1;
}
$authorIDString = $myRow["authorid"] ;
?>
INSERT INTO `serendipity_entries` VALUES (<?= $myRow["id"] ?>, '<?= mysql_escape_string($myRow["title"]) ?>', <?= $myRow["timestamp"] ?>, '<?= mysql_escape_string($bodyStr) ?>', 0, 0, '<?= mysql_escape_string($extendedStr) ?>', <?= $exFlag ?>, '', <?= $authorIDString ?>, 'false', 'true', <?= $myRow["timestamp"] ?>, 'false');
<?
}
?>
</pre>
I didn't need to import comments, but I assume that would be pretty straightforward.
Hope this helps someone.