From 547f839b07efa2ee6ddff956ed4fbd4c246768ab Mon Sep 17 00:00:00 2001 From: emc3 Date: Tue, 7 Oct 2003 19:56:49 +0000 Subject: [PATCH] Added safety checks for duplicate posts. git-svn-id: http://svn.automattic.com/wordpress/trunk@428 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- blogger-2-wp.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/blogger-2-wp.php b/blogger-2-wp.php index 12f4cf734a..90277a97ad 100644 --- a/blogger-2-wp.php +++ b/blogger-2-wp.php @@ -20,10 +20,10 @@ switch ($action) { case "step1": - require('wp-config.php'); - require($abspath.$b2inc.'/b2template.functions.php'); - require($abspath.$b2inc.'/b2functions.php'); - require($abspath.$b2inc.'/b2vars.php'); + require_once('wp-config.php'); + require_once($abspath.$b2inc.'/b2template.functions.php'); + require_once($abspath.$b2inc.'/b2functions.php'); + require_once($abspath.$b2inc.'/b2vars.php'); ?> @@ -60,7 +60,10 @@ case "step1": $postinfo = explode('|||', $posts[$i]); $post_date = $postinfo[0]; $post_content = $postinfo[2]; - $post_number = $postinfo[3]; + // Don't try to re-use the original numbers + // because the new, longer numbers are too + // big to handle as ints. + //$post_number = $postinfo[3]; $post_title = $postinfo[4]; $post_author = trim(addslashes($postinfo[1])); @@ -128,12 +131,21 @@ case "step1": $post_content = str_replace('
', '
', $post_content); // the XHTML touch... ;) $post_title = addslashes($post_title); + + // Quick-n-dirty check for dups: + $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $tableposts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A); + if ($dupcheck[0]['ID']) { + print "
\nSkipping duplicate post, ID = '" . $dupcheck[0]['ID'] . "'
\n"; + print "Timestamp: " . $post_date . "
\n"; + print "Post Title: '" . stripslashes($post_title) . "'
\n"; + continue; + } $result = $wpdb->query(" INSERT INTO $tableposts - (ID, post_author,post_date,post_content,post_title,post_category) + (post_author,post_date,post_content,post_title,post_category) VALUES - ('$post_number','$post_author_ID','$post_date','$post_content','$post_title','1') + ('$post_author_ID','$post_date','$post_content','$post_title','1') ");