diff --git a/wp-admin/import-rss.php b/wp-admin/import-rss.php
index 02bb13b110..822575637f 100644
--- a/wp-admin/import-rss.php
+++ b/wp-admin/import-rss.php
@@ -8,6 +8,11 @@ define('RSSFILE', '');
$post_author = 1; // Author to import posts as author ID
$timezone_offset = 0; // GMT offset of posts your importing
+function unhtmlentities($string) { // From php.net for < 4.3 compat
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+}
$add_hours = intval($timezone_offset);
$add_minutes = intval(60 * ($timezone_offset - $add_hours));
@@ -57,14 +62,14 @@ switch($step) {
define('RSSFILE', '');
You want to define where the RSS file we'll be working with is, for example:
define('RSSFILE', 'rss.xml');
-You have to do this manually for security reasons.
-If you've done that and you’re all ready, let's go!
+You have to do this manually for security reasons. When you're done reload this page and we'll take you to the next step.
+
+
+
previous page to continue.");
// Bring in the data
set_magic_quotes_runtime(0);
@@ -93,7 +98,7 @@ if (!$date) : // if we don't already have something from pubDate
$date = strtotime($date);
endif;
-$post_date = date('Y-m-d H:i:s', $date);
+$post_date = gmdate('Y-m-d H:i:s', $date);
preg_match_all('|(.*?)|is', $post, $categories);
$categories = $categories[1];
@@ -108,11 +113,24 @@ $content = str_replace( array(''), '', addslashes( trim($content
if (!$content) : // This is for feeds that put content in description
preg_match('|(.*?)|is', $post, $content);
- $content = addslashes( trim($content[1]) );
+ $content = $wpdb->escape( unhtmlentities( trim($content[1]) ) );
+endif;
+
+// Clean up content
+$content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $content);
+$content = str_replace('
', '
', $content);
+$content = str_replace('
', '
', $content);
+
+// This can mess up on posts with no titles, but checking content is much slower
+// So we do it as a last resort
+if ('' == $title) :
+ $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_content = '$content' AND post_date = '$post_date'");
+else :
+ $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'");
endif;
// Now lets put it in the DB
-if ($wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'")) :
+if ($dupe) :
echo 'Post already imported';
else :
@@ -124,6 +142,7 @@ else :
if (!$post_id) die("couldn't get post ID");
if (0 != count($categories)) :
foreach ($categories as $post_category) :
+ $post_category = unhtmlentities($post_category);
// See if the category exists yet
$cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'");
if (!$cat_id && '' != trim($post_category)) {