My company long used Metadot as our internal intranet for years, but have since moved to TikiWiki since support for Metadot is nearly dead.
This script will help you move articles from Metadot to TikiWiki.
Requirements: TikiWiki "HTML" Plugin must be enabled
Warning: Backup your TikiWiki database before trying this script. It worked for my setup, but may cause yours to blowup.
/**************************************
This script will transfer articles in metadot to tikiwiki wiki pages
***************************************/
//Metadot DB Info
$metadotdburl = "localhost";
$metadotdbuser = "username";
$metadotdbpass = "password";
$metadotdbname = "metadotdb";
//TikiWiki DB Info
$tikidburl = "localhost";
$tikidbuser = "username";
$tikidbpass = "password";
$tikidbname = "tikiwiki";
/**************************************
Only edit the variable above this line
***************************************/
echo "Starting...\n";
$db = mysql_connect($metadotdburl, $metadotdbuser, $metadotdbpass);
if (!$db) { die('Could not connect: ' . mysql_error()); }
echo "Connected successfully to Metadot database.\n";
$db_selected = mysql_select_db($metadotdbname, $db);
if (!$db_selected) {
die ('Can\'t use '.$metadotdbname.' : ' . mysql_error());
}
$sSql = "SELECT DISTINCT name,description,longdescription,UNIX_TIMESTAMP(UpdateDate),UNIX_TIMESTAMP(CreationDate) FROM instance where name<>'' AND description<>'' AND isA='Category' GROUP BY name;";
$nResult = mysql_query($sSql);
$num = mysql_numrows($nResult);
echo "Converting " . $num . " articles.\n";
$i=0;
mysql_close();
$db = mysql_connect($tikidburl, $tikidbuser, $tikidbpass);
if (!$db) { die('Could not connect to '.$tikidburl.': ' . mysql_error()); }
echo "Connected successfully to TikiWiki database.\n";
$db_selected = mysql_select_db($tikidbname, $db);
if (!$db_selected) {
die ('Can\'t use '.$tikidbname.' : ' . mysql_error());
}
while ($i < $num) {
$pageName = mysql_result($nResult, $i, "name");;
$data = mysql_result($nResult, $i, "description");;
$description = mysql_result($nResult, $i, "longdescription");;
$lastModif = mysql_result($nResult, $i, "UNIX_TIMESTAMP(UpdateDate)");;
// $page_size = mysql_result($nResult, $i, "PacketNum");; //size of $data in bits.
$created = mysql_result($nResult, $i, "UNIX_TIMESTAMP(CreationDate)");;
$data = "{HTML()}" . $data . "{HTML}";
$data = ($data);
$sSql = "INSERT INTO tiki_pages(pageName,hits,data,description,lastModif,version,user,IP,cache_timestamp,is_html,created,wysiwyg,version_minor) VALUES('".addslashes($pageName)."','0','".mysql_real_escape_string(htmlspecialchars($data))."','".addslashes($description)."','".$lastModif."','1','admin','1.1.1.1','0','0','".$created."','n','0')";
$result = mysql_query($sSql);
if (!$result) {
echo "Invalid query: " . mysql_error() ."\n";
} else {
echo "TikiWiki Page " .$pageName. " has been created.\n";
}
$i++;
}
echo "Complete";
mysql_close();
?>
Showing posts with label metadit. Show all posts
Showing posts with label metadit. Show all posts
Thursday, April 29, 2010
Subscribe to:
Posts (Atom)