\n
$string = str_replace("|*|"," \n",$string);
return($string);
}
if (!chdir($archivespath))
die("Wrong path, $archivespath\ndoesn't exist\non the server");
if (!chdir($gmpath))
die("Wrong path, $gmpath\ndoesn't exist\non the server");
?>
GM 2 b2 - converting...
gm 2
The importer is running...
importing users...
get_var("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'");
if ($loginthere) {
echo "
user $user_login... Already exists
";
continue;
}
$query = "INSERT INTO $tableusers (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','1','nickname')";
$result = mysql_query($query);
if ($result==false) {
die ("ERROR: couldn't register an user... please contact the webmaster !");
}
echo "
user $user_login... Done
";
}
?>
Done
importing posts, comments, and karma...
entry # $entryfile ";
$postinfo=explode("|",$entry[0]);
$postmaincontent=gm2autobr($entry[2]);
$postmorecontent=gm2autobr($entry[3]);
$post_author=trim(addslashes($postinfo[1]));
// we'll check the author is registered, or if it's a deleted author
$sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'";
$result = mysql_query($sql);
if (!mysql_num_rows($result)) { // if deleted from GM, we register the author as a level 0 user in b2
$user_ip="127.0.0.1";
$user_domain="localhost";
$user_browser="server";
$user_joindate="1979-06-06 00:41:00";
$user_login=addslashes($post_author);
$pass1=addslashes("password");
$user_nickname=addslashes($post_author);
$user_email=addslashes("user@deleted.com");
$user_url=addslashes("");
$user_joindate=addslashes($user_joindate);
$query = "INSERT INTO $tableusers (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','0','nickname')";
$result = mysql_query($query);
if ($result==false) {
die ("ERROR: couldn't register an user... please contact the webmaster !");
}
echo ": registered deleted user $user_login at level 0 ";
}
$sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$post_author_ID=$myrow[0];
$post_title=gm2autobr($postinfo[2]);
$post_title=addslashes($post_title);
$postyear=$postinfo[6];
$postmonth=zeroise($postinfo[4],2);
$postday=zeroise($postinfo[5],2);
$posthour=zeroise($postinfo[7],2);
$postminute=zeroise($postinfo[8],2);
$postsecond=zeroise($postinfo[9],2);
if (($postinfo[10]=="PM") && ($posthour!="12"))
$posthour=$posthour+12;
$post_date="$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
$post_content=$postmaincontent;
if (strlen($postmorecontent)>3)
$post_content .= "
".$postmorecontent;
$post_content=addslashes($post_content);
$post_karma=$postinfo[12];
$query = "INSERT INTO $tableposts (post_author,post_date,post_content,post_title) VALUES ('$post_author_ID','$post_date','$post_content','$post_title')";
$result = mysql_query($query) or die(mysql_error());
if (!$result)
die ("Error in posting... contact the webmaster");
$sql2 = "SELECT * FROM $tableposts WHERE 1=1 ORDER BY ID DESC LIMIT 1";
$result2 = mysql_query($sql2);
$myrow2 = mysql_fetch_array($result2);
$post_ID=$myrow2[0];
// Grab a default category.
$post_category = $wpdb->get_var("SELECT cat_ID FROM $tablecategories LIMIT 1");
// Update the post2cat table.
$exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category");
if (!$exists) {
$wpdb->query("
INSERT INTO $tablepost2cat
(post_id, category_id)
VALUES
($post_ID, $post_category)
");
}
$c=count($entry);
if ($c>4) {
for ($j=4;$j<$c;$j++) {
$entry[$j]=gm2autobr($entry[$j]);
$commentinfo=explode("|",$entry[$j]);
$comment_post_ID=$post_ID;
$comment_author=addslashes($commentinfo[0]);
$comment_author_email=addslashes($commentinfo[2]);
$comment_author_url=addslashes($commentinfo[3]);
$comment_author_IP=addslashes($commentinfo[1]);
$commentyear=$commentinfo[7];
$commentmonth=zeroise($commentinfo[5],2);
$commentday=zeroise($commentinfo[6],2);
$commenthour=zeroise($commentinfo[8],2);
$commentminute=zeroise($commentinfo[9],2);
$commentsecond=zeroise($commentinfo[10],2);
if (($commentinfo[11]=="PM") && ($commenthour!="12"))
$commenthour=$commenthour+12;
$comment_date="$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";
$comment_content=addslashes($commentinfo[12]);
$sql3 = "INSERT INTO $tablecomments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')";
$result3 = mysql_query($sql3);
if (!$result3)
die ("There is an error with the database, it can't store your comment... Contact the webmaster");
}
$comments=$c-4;
echo ": imported $comments comment";
if ($comments>1)
echo "s";
}
echo "... Done
This is a basic GreyMatter to WordPress import script.
What it does:
parses gm-authors.cgi to import authors: everyone is imported at level 1
parses the entries cgi files to import posts, comments, and karma on posts (although karma is not used on WordPress yet) if authors are found not to be in gm-authors.cgi, imports them at level 0
What it does not:
parse gm-counter.cgi (what's the use of that file ?), gm-banlist.cgi, gm-cplog.cgi (you can make a CP log hack if you really feel like it, but I question the need of a CP log)
import gm-templates. you'll start with the basic template wp.php
doesn't keep entries on top
First step: install WordPress
Install the WordPress blog as explained in the ReadMe, then immediately come back here.