Error: $s"; } // line breaks into properly formatted paragraphs function paragraph($text, $br = false) { $text=trim($text); $text = str_replace("\r",'',$text); $text = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $text); if ($text=="") return ""; $text = $text . "\n"; // just to make things a little easier, pad the end $text = preg_replace('|
\s*
|', "\n\n", $text); $text = preg_replace('!(<(?:table|ul|ol|li|pre|form|blockquote|h[1-6])[^>]*>)!', "\n$1", $text); // Space things out a little $text = preg_replace('!()!', "$1\n", $text); // Space things out a little $text = preg_replace("/(\r\n|\r)/", "\n", $text); // cross-platform newlines $text = preg_replace("/\n\n+/", "\n\n", $text); // take care of duplicates $text = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "\t

$1

\n", $text); // make paragraphs, including one at the end $text = preg_replace('|

\s*?

|', '', $text); // under certain strange conditions it could create a P of entirely whitespace $text = preg_replace("|

(|", "$1", $text); // problem with nested lists // blockquote $text = preg_replace('|

]*)>|i', "

", $text); $text = str_replace('

', '

', $text); // now the hard work $text = preg_replace('!

\s*(]*>)!', "$1", $text); $text = preg_replace('!(]*>)\s*

|"!', "$1", $text); if ($br) $text = preg_replace('|(?)\s*\n|', "
\n", $text); // optionally make line breaks $text = preg_replace('!(]*>)\s*
!', "$1", $text); $text = preg_replace('!
(\s*)!', '$1', $text); // some cleanup $text = str_replace('


','

',$text); $text = str_replace("
\n

",'

',$text); return $text; } function encoding($s){ global $input; if (is_callable("iconv")) return iconv($input,'utf-8',$s); else return $s; } ?> WordPress to Nucleus CMS convertor

WordPress »» Nucleus CMS »» convertor

This tool will convert your WordPress blog (tested w/ 3.1.x), into Nucleus CMS weblog. First, install Nucleus, in a default install, and only after that run this tool. It will transfer all categories, posts, and comments into blog #1.

Please correct these errors first!


"; } else { /* */ /* transfer data ! */ /* */ $prefixwp = $_POST['wpprefix']; /* *********************************************** */ echo "

Getting encoding...

"; $query = "SELECT option_value FROM " . $prefixwp . "options WHERE option_name='blog_charset'"; $querywp = mysql_query($query, $linkwp) or die($query); if ( $row = mysql_fetch_object($querywp) ) $input = $row->option_value; else $input = "utf-8"; echo "

Encoding: $input

"; /* *********************************************** */ echo "

Transfering categories...

"; DB::execute("DELETE FROM " . sql_table('category') . " WHERE cdesc='@wordpress'"); $total_num = DB::getValue("SELECT count(*) as result FROM " . sql_table('category')); $catdd = $total_num; $total_num++; $query = "SELECT * FROM " . $prefixwp . "term_taxonomy , " . $prefixwp . "terms WHERE " . $prefixwp . "term_taxonomy.term_taxonomy_id = " . $prefixwp . "terms.term_id AND " . $prefixwp . "term_taxonomy.taxonomy='category'"; $querywp = mysql_query($query, $linkwp) or die($query); echo "

rows to transfer: " . mysql_num_rows($querywp) . "

"; echo "

"; $cate_map = array(); while ( $row = mysql_fetch_object($querywp) ) { echo $total_num . ", "; $cate_map[$row->term_id] = $total_num; $query = sprintf("INSERT INTO %s (catid,cblog,cname,cdesc) VALUES (%d,1,'%s','@wordpress')" , sql_table('category'), intval($total_num), encoding($row->name)); if ( DB::execute($query) === FALSE ) { die($query); } $total_num++; } echo "

"; /* *********************************************** */ echo "

Transfering posts and comments...

"; DB::execute("DELETE FROM " . sql_table('comment') . " WHERE chost='@wordpress'"); $query = "SELECT * FROM " . $prefixwp . "posts WHERE post_status='publish' ORDER BY ID"; $querywp = mysql_query($query, $linkwp) or die($query); echo "

rows to transfer: " . mysql_num_rows($querywp) . "

"; echo "

"; $i = 1; while ( $row = mysql_fetch_object($querywp) ) { echo $i++ . ", "; // find category $query = 'SELECT * FROM ' . $prefixwp . 'term_relationships, ' . $prefixwp . 'term_taxonomy WHERE ' . $prefixwp . 'term_relationships.term_taxonomy_id=' . $prefixwp . 'term_taxonomy.term_taxonomy_id AND object_id=' . $row->ID . ' AND ' . $prefixwp . 'term_taxonomy.taxonomy=\'category\' LIMIT 1'; $catwp = mysql_query($query, $linkwp) or die($query); $category = mysql_fetch_object($catwp); $cat = $cate_map[$category->term_id]; if ( empty($cat) ) $cat = 1; // insert post $query = sprintf("INSERT INTO %s (ititle,ibody,iblog,iauthor,itime,icat) VALUES (%s,%s,1,1,'%s',%d)" , sql_table('item') , DB::quoteValue(encoding($row->post_title)) , DB::quoteValue(paragraph(encoding(stripslashes($row->post_content)), false)) , $row->post_date , $cat); if ( DB::execute($query) === FALSE ) { die($query); } $itemid = DB::getInsertId(); // insert comments $query = "SELECT * FROM " . $prefixwp . "comments WHERE comment_post_ID=" . $row->ID; $querywp_detail = mysql_query($query, $linkwp) or die($query); while ( $row_detail = mysql_fetch_object($querywp_detail) ) { $url = $row_detail->comment_author_email; if ( !empty($row_detail->comment_author_url) ) $url = $row_detail->comment_author_url; $query = sprintf("INSERT INTO %s (cbody,cuser,cmail,cmember,citem,ctime,cip,cblog,chost)" . " VALUES (%s,%s,%s,0,%d,'%s',%s,1,'@wordpress')" , sql_table('comment') , DB::quoteValue(paragraph(encoding(strip_tags(stripslashes($row_detail->comment_content))), true)) , encoding($row_detail->comment_author) , DB::quoteValue($url) , $itemid , $row_detail->comment_date , DB::quoteValue($row_detail->comment_author_IP)); if ( DB::execute($query) === FALSE ) { die($query); } } } echo "

"; // done echo "

Done! Enjoy your stay in Nucleus

"; die; } } ?>

WordPress (v3.1.x) Database Info

WP info



New Nucleus:CMS Database Info

Nucleus:CMS info



Submit