From e7557946d66c61751dd496f8c8631efd16190931 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Mon, 9 Feb 2004 08:41:08 +0000 Subject: [PATCH] Import fixes from Phil Ringnalda. git-svn-id: https://develop.svn.wordpress.org/trunk@847 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/import-mt.php | 64 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/wp-admin/import-mt.php b/wp-admin/import-mt.php index 195684b87c..ff70fd3bf5 100644 --- a/wp-admin/import-mt.php +++ b/wp-admin/import-mt.php @@ -80,7 +80,11 @@ foreach ($posts as $post) { if ('' != trim($post)) { $post = preg_replace("/(\r\n|\n|\r)/", "\n", $post); echo "
  • Importing post... "; - // Take the comments out first + // Take the pings out first + preg_match("|(-----\n\nPING:.*)|s", $post, $pings); + $post = preg_replace("|(-----\n\nPING:.*)|s", '', $post); + + // Then take the comments out preg_match("|(-----\nCOMMENT:.*)|s", $post, $comments); $post = preg_replace("|(-----\nCOMMENT:.*)|s", '', $post); @@ -130,9 +134,9 @@ foreach ($posts as $post) { if ('' != trim($post)) { case 'ALLOW COMMENTS': $post_allow_comments = $value; if ($post_allow_comments == 1) { - $post_allow_comments = "open"; + $comment_status = 'open'; } else { - $post_allow_comments = "closed"; + $comment_status = 'closed'; } break; case 'CONVERT BREAKS': @@ -141,9 +145,9 @@ foreach ($posts as $post) { if ('' != trim($post)) { case 'ALLOW PINGS': $post_allow_pings = trim($meta[2][0]); if ($post_allow_pings == 1) { - $post_allow_pings = "open"; + $post_allow_pings = 'open'; } else { - $post_allow_pings = "closed"; + $post_allow_pings = 'closed'; } break; case 'PRIMARY CATEGORY': @@ -222,10 +226,10 @@ foreach ($posts as $post) { if ('' != trim($post)) { $comment_date = trim($comment_date[1]); $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); $comment = preg_replace('|(\n?DATE:.*)|', '', $comment); - + $comment_content = addslashes(trim($comment)); $comment_content = str_replace('-----', '', $comment_content); - + // Check if it's already there if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { $wpdb->query("INSERT INTO $tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) @@ -235,6 +239,52 @@ foreach ($posts as $post) { if ('' != trim($post)) { } } } + + // Finally the pings + // fix the double newline on the first one + $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]); + $pings = explode("-----\nPING:", $pings[0]); + foreach ($pings as $ping) { + if ('' != trim($ping)) { + // 'Author' + preg_match("|BLOG NAME:(.*)|", $ping, $comment_author); + $comment_author = addslashes(trim($comment_author[1])); + $ping = preg_replace('|(\n?BLOG NAME:.*)|', '', $ping); + + $comment_email = ''; + + preg_match("|IP:(.*)|", $ping, $comment_ip); + $comment_ip = trim($comment_ip[1]); + $ping = preg_replace('|(\n?IP:.*)|', '', $ping); + + preg_match("|URL:(.*)|", $ping, $comment_url); + $comment_url = addslashes(trim($comment_url[1])); + $ping = preg_replace('|(\n?URL:.*)|', '', $ping); + + preg_match("|DATE:(.*)|", $ping, $comment_date); + $comment_date = trim($comment_date[1]); + $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); + $ping = preg_replace('|(\n?DATE:.*)|', '', $ping); + + preg_match("|TITLE:(.*)|", $ping, $ping_title); + $ping_title = addslashes(trim($ping_title[1])); + $ping = preg_replace('|(\n?TITLE:.*)|', '', $ping); + + $comment_content = addslashes(trim($ping)); + $comment_content = str_replace('-----', '', $comment_content); + + $comment_content = "$ping_title\n$comment_content"; + + // Check if it's already there + if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) { + $wpdb->query("INSERT INTO $tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved) + VALUES + ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')"); + echo " Comment added."; + } + + } + } } echo "
  • "; flush();