Update greymatter importer to use wpdb. Needs testing, but it can't be more broken than before. :-)
git-svn-id: http://svn.automattic.com/wordpress/trunk@2564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d877c39976
commit
4dad093159
|
@ -25,7 +25,7 @@ switch ($action) {
|
|||
|
||||
case "step1":
|
||||
|
||||
function gm2autobr($string) { // transforms GM's |*| into b2's <br />\n
|
||||
function gm2autobr($string) { // transforms GM's |*| into wp's <br />\n
|
||||
$string = str_replace("|*|","<br />\n",$string);
|
||||
return($string);
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ case "step1":
|
|||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>GM 2 b2 - converting...</title>
|
||||
<link rel="stylesheet" href="wp-admin/b2.css" type="text/css">
|
||||
<title>GM 2 WordPress - converting...</title>
|
||||
<link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
<?php
|
||||
|
@ -60,7 +60,7 @@ textarea,input,select {
|
|||
</style>
|
||||
</head>
|
||||
<body style="margin: 20px;">
|
||||
<p><font face="times new roman" style="font-size: 39px;">gm 2 <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WP" align="top" /></font></p>
|
||||
<p><font face="times new roman" style="font-size: 39px;">gm 2 <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WordPress" align="top" /></font></p>
|
||||
<p>The importer is running...</p>
|
||||
<ul>
|
||||
<li>importing users... <ul><?php
|
||||
|
@ -68,9 +68,6 @@ textarea,input,select {
|
|||
chdir($gmpath);
|
||||
$userbase = file("gm-authors.cgi");
|
||||
|
||||
$connexion = mysql_connect($server,$loginsql,$passsql) or die ("Oops, MySQL connection error ! Couldn't connect to $server with the username $loginsql");
|
||||
$bdd = mysql_select_db(DB_NAME,$connexion) or die ("Oops, can't find any database named DB_NAME here !");
|
||||
|
||||
foreach($userbase as $user) {
|
||||
$userdata=explode("|", $user);
|
||||
|
||||
|
@ -95,7 +92,7 @@ textarea,input,select {
|
|||
}
|
||||
|
||||
$query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,user_registered,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);
|
||||
$result = $wpdb->query($query);
|
||||
if ($result==false) {
|
||||
die ("<strong>ERROR</strong>: couldn't register an user!");
|
||||
}
|
||||
|
@ -141,8 +138,8 @@ textarea,input,select {
|
|||
$post_author=trim(addslashes($postinfo[1]));
|
||||
// we'll check the author is registered, or if it's a deleted author
|
||||
$sql = "SELECT * FROM $wpdb->users 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
|
||||
$result = $wpdb->query($sql);
|
||||
if (! $result) { // if deleted from GM, we register the author as a level 0 user in wp
|
||||
$user_ip="127.0.0.1";
|
||||
$user_domain="localhost";
|
||||
$user_browser="server";
|
||||
|
@ -154,17 +151,15 @@ textarea,input,select {
|
|||
$user_url=addslashes("");
|
||||
$user_joindate=addslashes($user_joindate);
|
||||
$query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,user_registered,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);
|
||||
$result = $wpdb->query($query);
|
||||
if ($result==false) {
|
||||
die ("<strong>ERROR</strong>: couldn't register an user!");
|
||||
}
|
||||
echo ": registered deleted user <i>$user_login</i> at level 0 ";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'";
|
||||
$result = mysql_query($sql);
|
||||
$myrow = mysql_fetch_array($result);
|
||||
$post_author_ID=$myrow[0];
|
||||
$sql = "SELECT ID FROM $wpdb->users WHERE user_login = '$post_author'";
|
||||
$post_author_ID = $wpdb->get_var($sql);
|
||||
|
||||
$post_title=gm2autobr($postinfo[2]);
|
||||
$post_title=addslashes($post_title);
|
||||
|
@ -189,15 +184,13 @@ textarea,input,select {
|
|||
$post_karma=$postinfo[12];
|
||||
|
||||
$query = "INSERT INTO $wpdb->posts (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());
|
||||
$result = $wpdb->query($query);
|
||||
|
||||
if (!$result)
|
||||
die ("Error in posting...");
|
||||
|
||||
$sql2 = "SELECT * FROM $wpdb->posts ORDER BY ID DESC LIMIT 1";
|
||||
$result2 = mysql_query($sql2);
|
||||
$myrow2 = mysql_fetch_array($result2);
|
||||
$post_ID=$myrow2[0];
|
||||
$query = "SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1";
|
||||
$post_ID = $wpdb->get_var($query);
|
||||
|
||||
// Grab a default category.
|
||||
$post_category = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories LIMIT 1");
|
||||
|
@ -238,7 +231,7 @@ textarea,input,select {
|
|||
$comment_content=addslashes($commentinfo[12]);
|
||||
|
||||
$sql3 = "INSERT INTO $wpdb->comments (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);
|
||||
$result3 = $wpdb->query($sql3);
|
||||
if (!$result3)
|
||||
die ("There is an error with the database, it can't store your comment..");
|
||||
}
|
||||
|
@ -254,7 +247,7 @@ textarea,input,select {
|
|||
?>
|
||||
</ul><b>Done</b></li></ul>
|
||||
<p> </p>
|
||||
<p>Completed GM 2 b2 import !</p>
|
||||
<p>Completed GM 2 WordPress import !</p>
|
||||
<p>Now you can go and <a href="wp-login.php">log in</a>, have fun !</p>
|
||||
<?php
|
||||
break;
|
||||
|
@ -268,8 +261,8 @@ default:
|
|||
|
||||
?><html>
|
||||
<head>
|
||||
<title>GM 2 b2 importer utility</title>
|
||||
<link rel="stylesheet" href="wp-admin/b2.css" type="text/css">
|
||||
<title>GM 2 WordPress importer utility</title>
|
||||
<link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
<?php
|
||||
|
@ -290,7 +283,7 @@ textarea,input,select {
|
|||
</style>
|
||||
</head>
|
||||
<body style="margin: 20px;">
|
||||
<p><font face="times new roman" style="font-size: 39px;">gm 2 <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WP" align="top" /></font></p>
|
||||
<p><font face="times new roman" style="font-size: 39px;">gm 2 <img src="../wp-images/wpminilogo.png" width="50" height="50" border="0" alt="WordPress" align="top" /></font></p>
|
||||
<p>This is a basic GreyMatter to WordPress import script.</p>
|
||||
<p>What it does:</p>
|
||||
<ul>
|
||||
|
|
Loading…
Reference in New Issue