wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."); if (!file_exists('config.php')) die("There doesn't seem to be a config.php file. Please open the sample-config.php, add your Mambo database name and resave it as config.php."); require_once('../wp-config.php'); //require_once('./upgrade-functions.php'); require_once('config.php'); $guessurl = str_replace('/wp-admin/install.php?step=2', '', 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ); $action=$_GET['action']; $id=$_GET['select']; $category=$_GET['category']; if ($category == "") { $category=$_POST['category']; } $section=$_GET['section']; if ($section == "") { $section=$_POST['section']; } $wpsection=$_GET['wpsection']; if ($wpsection == "") { $wpsection=$_POST['wpsection']; } if (isset($_GET['step'])) $step = $_GET['step']; else $step = 0; ?> Mambo2WordPress › Import

Mambo2WordPress Import Wizard

hide_errors(); $installed = $wpdb->get_results("SELECT * FROM $wpdb->users"); if ($installed) die(__('

Already Installed

You appear to have already installed WordPress. To reinstall please clear your old database tables first.

')); $wpdb->show_errors(); */ switch($step) { case 0: ?>

Welcome to the Mambo2WordPress import wizard. With this wizard you can import articles from a Mambo installation to a WordPress installation as long as they're both on the same host.

Since we've come this far, you've already created a config.php file.  Make sure the Mambo database name is okay, then click through to step one and we'll test to make sure we've got the connections to our databases.

Step One »

Could not select database

"); ?>

Step One

Okay, we're connected to the Mambo database.

Now, we need to select the method you want to use to import your articles or links. (You should automatically advance to the next step, but if it doesn't you can click the button.)

Query failed"); /*****************************************/ /* Write the form with the section names */ /*****************************************/ ?>

Import articles from a whole section:

Import articles from just one category:

Import links from just a category:

Step Two"; $link = mysql_connect("$dbihost", "$dbiuser", "$dbipass") or die("

Could not connect

"); //print "Connected successfully"; mysql_select_db("$dbi") or die("

Could not select database

"); $query = "SELECT cat_ID, cat_name FROM `wp_categories`"; $result = mysql_query($query) or die("Query failed"); ?>

Select a WordPress category to import from your section.

Back to step 1

Step Two"; $link = mysql_connect("$dbihost", "$dbiuser", "$dbipass") or die("

Could not connect

"); //print "Connected successfully"; mysql_select_db("$dbi") or die("

Could not select database

"); $query = "SELECT cat_ID, cat_name FROM `wp_categories`"; $result = mysql_query($query) or die("Query failed"); ?>

Select a WordPress section to import from your category.

Back to step 1

Step Three"; //echo "

".$section."

"; //echo "

".$wpsection."

"; /* Make connection to Mambo (exporting) database */ $link = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("Could not connect"); //print "Connected successfully"; mysql_select_db("$dbh") or die("Could not select database"); /* Performing SQL query */ $query = "SELECT id, title, introtext, `fulltext`, created, modified FROM mos_content WHERE `sectionid` = '$section'"; //echo $query."
\n"; $result = mysql_query($query) or die("Query failed"); /* Load database values into an array, making sure to escape them for quotes, etc. */ $i = 0; while ($row = mysql_fetch_assoc($result)) { $import[0][$i] = mysql_escape_string($row["id"]); $import[1][$i] = mysql_escape_string($row["title"]); $import[2][$i] = mysql_escape_string($row["introtext"]."

".$row["fulltext"]); $import[3][$i] = mysql_escape_string($row["created"]); $import[4][$i] = mysql_escape_string($row["modified"]); $i++; } /* Free result set */ mysql_free_result($result); /* Closing connection */ mysql_close($link); /* For debugging purposes */ /* $j = 0; echo "i = ".$i."
"; while ($j < $i) { echo "id: ".$import[0][$j]."
\n"; echo "title: ".$import[1][$j]."
\n"; echo "introtext: ".$import[2][$j]."
\n"; echo "created: ".$import[3][$j]."
\n"; echo "modified: ".$import[4][$j]."

\n"; $j++; } */ echo "Importing ".$i." item"; if ($i != 1) { echo "s"; } /* Make connection to Word Pro (importing) database */ $link = mysql_connect("$dbihost", "$dbiuser", "$dbipass") or die("

Could not connect

"); //print "Connected successfully"; mysql_select_db("$dbi") or die("

Could not select database

"); $j = 0; while ($j < $i) { /* Create an acceptable WP post_name */ $post_name = sanitize_title_with_dashes($import[1][$j]); /* Do the actual query */ $query = "INSERT INTO wp_posts (id, post_title, post_content, post_date, post_modified, post_name, post_category) VALUES ('', '{$import[1][$j]}', '{$import[2][$j]}', '{$import[3][$j]}', '{$import[4][$j]}', '$post_name', '$wpsection')"; /* For debugging purposes */ echo "
".$query."
"; $result = mysql_query($query) or die("

Query failed

"); $j++; } /* Closing connection */ mysql_close($link); ?>

Finished!

Go back to the beginning.

\n"; break; case 5: require_once ("../wp-includes/functions-formatting.php"); require_once ("../wp-includes/functions.php"); echo "

Second Step

"; //echo "

".$section."

"; //echo "

".$wpsection."

"; /* Make connection to Mambo (exporting) database */ $link = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("Could not connect"); //print "Connected successfully"; mysql_select_db("$dbh") or die("Could not select database"); /* Performing SQL query */ $query = "SELECT id, title, introtext, `fulltext`, created, modified FROM mos_content WHERE `sectionid` = '$category'"; //echo $query."
\n"; $result = mysql_query($query) or die("Query failed"); /* Load database values into an array, making sure to escape them for quotes, etc. */ $i = 0; while ($row = mysql_fetch_assoc($result)) { $import[0][$i] = mysql_escape_string($row["id"]); $import[1][$i] = mysql_escape_string($row["title"]); $import[2][$i] = mysql_escape_string($row["introtext"]."

".$row["fulltext"]); $import[3][$i] = mysql_escape_string($row["created"]); $import[4][$i] = mysql_escape_string($row["modified"]); $i++; } /* Free result set */ mysql_free_result($result); /* Closing connection */ mysql_close($link); /* For debugging purposes */ /* $j = 0; echo "i = ".$i."
"; while ($j < $i) { echo "id: ".$import[0][$j]."
\n"; echo "title: ".$import[1][$j]."
\n"; echo "introtext: ".$import[2][$j]."
\n"; echo "created: ".$import[3][$j]."
\n"; echo "modified: ".$import[4][$j]."

\n"; $j++; } */ echo "Importing ".$i." item"; if ($i != 1) { echo "s"; } /* Make connection to Word Pro (importing) database */ $link = mysql_connect("$dbihost", "$dbiuser", "$dbipass") or die("

Could not connect

"); //print "Connected successfully"; mysql_select_db("$dbi") or die("

Could not select database

"); $j = 0; while ($j < $i) { /* Create an acceptable WP post_name */ $post_name = sanitize_title_with_dashes($import[1][$j]); /* Do the actual query */ $query = "INSERT INTO wp_posts (id, post_title, post_content, post_date, post_modified, post_name, post_category) VALUES ('', '{$import[1][$j]}', '{$import[2][$j]}', '{$import[3][$j]}', '{$import[4][$j]}', '$post_name', '$wpsection')"; /* For debugging purposes */ echo "
".$query."
"; $result = mysql_query($query) or die("

Query failed

"); $j++; } /* Closing connection */ mysql_close($link); ?>

Finished!

Go back to the beginning.

\n"; break; case 6: // Select a WP link category to import from the category. echo "

Step Two

"; $link = mysql_connect("$dbihost", "$dbiuser", "$dbipass") or die("

Could not connect

"); //print "Connected successfully"; mysql_select_db("$dbi") or die("

Could not select database

"); $query = "SELECT cat_id, cat_name FROM `wp_linkcategories`"; $result = mysql_query($query) or die("Query failed"); ?>

Select a WordPress category to import from your section.

Back to step 1

Step Three"; echo "

Category= ".$category."

"; echo "

WPsection= ".$wpsection."

"; /* Make connection to Mambo (exporting) database */ $link = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("Could not connect"); //print "Connected successfully"; mysql_select_db("$dbh") or die("Could not select database"); /* Performing SQL query */ $query = "SELECT title, url, `description` FROM mos_weblinks WHERE `catid` = '$category'"; //echo $query."
\n"; $result = mysql_query($query) or die("Query failed"); /* Load database values into an array, making sure to escape them for quotes, etc. */ $i = 0; while ($row = mysql_fetch_assoc($result)) { $import[0][$i] = mysql_escape_string($row["title"]); $import[1][$i] = mysql_escape_string($row["url"]); $import[2][$i] = mysql_escape_string($row["description"]); $i++; } /* Free result set */ mysql_free_result($result); /* Closing connection */ mysql_close($link); /* For debugging purposes */ /* $j = 0; echo "i = ".$i."
"; while ($j < $i) { echo "id: ".$import[0][$j]."
\n"; echo "title: ".$import[1][$j]."
\n"; echo "introtext: ".$import[2][$j]."
\n"; echo "created: ".$import[3][$j]."
\n"; echo "modified: ".$import[4][$j]."

\n"; $j++; } */ echo "Importing ".$i." item"; if ($i != 1) { echo "s"; } /* Make connection to Word Pro (importing) database */ $link = mysql_connect("$dbihost", "$dbiuser", "$dbipass") or die("

Could not connect

"); //print "Connected successfully"; mysql_select_db("$dbi") or die("

Could not select database

"); $j = 0; while ($j < $i) { /* Create an acceptable WP post_name */ //$post_name = sanitize_title_with_dashes($import[1][$j]); /* Do the actual query */ $query = "INSERT INTO wp_links (link_id, link_url, link_name, link_description, link_category) VALUES ('', '{$import[1][$j]}', '{$import[0][$j]}', '{$import[2][$j]}', '$wpsection')"; /* For debugging purposes */ echo "
".$query."
"; $result = mysql_query($query) or die("

Query failed

"); $j++; } /* Closing connection */ mysql_close($link); ?>

Finished!

Go back to the beginning.

\n"; break; } ?>