Science And Technology

I downloaded this, but it didn't work with my version of agora 3.0.13 So I wrote the following script to do the migration. This script only works one topic/thread at a time. So you'll have to create your categories in kunena first. I only had about 7-8 categories in agora so I didn't write a script for that. Anyways, in order to use this you just need to change the id for t.forum_id to match the agora category/forum then change the $cat_id variable to match your new kunena category. Maybe someone else might need it.
 
//enter your database credentials here.
$host = "";
$user = "";
$pass = "";
$db = "";
 
$link = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_selectdb($db,$link) or die(mysql_error());
 
//get the total thread count so we know where to start inserting posts.
$sql = "SELECT COUNT(id) AS total FROM j17_kunena_messages";
$res = mysql_query($sql) or die(mysql_error());
$res = mysql_fetch_object($res);
$thread = $res->total+1;
 
//manually change the t.forum_id to match the agora forum id. (forums are categories in kunena)
//manually change the table prefix as well. 
//t.forum_id = agora_topics.forum_id
$sql = "
SELECT p.message, p.poster AS mes_poster, t.poster AS topic_poster, t.subject, u.id AS user_id, u.email, p.posted, t.num_views
FROM j15_agora_topics AS t
LEFT JOIN j15_agora_posts AS p ON p.topic_id = t.id
LEFT JOIN j15_users AS u ON u.username = p.poster
WHERE t.forum_id = 6
ORDER BY p.topic_id ASC
";
 
//manually change the cat_id to match the category id from kunena
//cat_id == kunena_messages table
$cat_id = 10;
$parent_id = 0;
$subject = '';
$i = $thread;
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_object($res))
{        
        if($row->subject != $subject && $i != 0)
        {
            $thread = $i;
            $parent_id = 0;            
        }
 
        $sql = "INSERT INTO j17_kunena_messages VALUES (0, ".$parent_id.", ".$thread.", ".$cat_id.", '".$row->poster."', ".$row->user_id.", '".$row->email."', '".mysql_escape_string($row->subject)."', ".$row->posted.", 0, 0, 0, 0, 0, ".$row->num_views.", 0, NULL, NULL, NULL)";
 
        echo $sql;
        mysql_query($sql) or die(mysql_error());
        $id = mysql_insert_id();
        //if($parent_id == 0)
        $sql = "INSERT INTO j17_kunena_messages_text VALUES (".$id.", '".mysql_escape_string($row->message)."')";
 
 
        mysql_query($sql) or die(mysql_error());
        echo $sql . "";
    if($parent_id == 0)
        $parent_id = $id;    
    $subject = $row->subject;
    $i++;
}
 
echo $thread;
mysql_close();
 

OOPS! I messed up!

You'll want this script to reset your kunena tables if you mess up. After you're finished go to the back end of kunena and recount the categories.
 
DROP TABLE j17_kunena_messages;
DELETE FROM j17_kunena_messages_text;
 
CREATE TABLE IF NOT EXISTS `j17_kunena_messages` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `parent` INT(11) DEFAULT '0',
  `thread` INT(11) DEFAULT '0',
  `catid` INT(11) NOT NULL DEFAULT '0',
  `name` tinytext,
  `userid` INT(11) NOT NULL DEFAULT '0',
  `email` tinytext,
  `subject` tinytext,
  `time` INT(11) NOT NULL DEFAULT '0',
  `ip` VARCHAR(15) DEFAULT NULL,
  `topic_emoticon` INT(11) NOT NULL DEFAULT '0',
  `locked` tinyint(4) NOT NULL DEFAULT '0',
  `hold` tinyint(4) NOT NULL DEFAULT '0',
  `ordering` INT(11) DEFAULT '0',
  `hits` INT(11) DEFAULT '0',
  `moved` tinyint(4) DEFAULT '0',
  `modified_by` INT(7) DEFAULT NULL,
  `modified_time` INT(11) DEFAULT NULL,
  `modified_reason` tinytext,
  PRIMARY KEY  (`id`),
  KEY `thread` (`thread`),
  KEY `ip` (`ip`),
  KEY `userid` (`userid`),
  KEY `time` (`time`),
  KEY `locked` (`locked`),
  KEY `hold_time` (`hold`,`time`),
  KEY `parent_hits` (`parent`,`hits`),
  KEY `catid_parent` (`catid`,`parent`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;