Running Fix: Comment Authors '.$testonly.' '; echo '
'; $link = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $link->autocommit(TRUE); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $SQL = "SELECT comment_id, comment_author FROM wp_comments"; if (! $results = $link->query($SQL) ) { printf("Errormessage: %s\n", $link->error); $link->close(); exit(); } while ($row = $results->fetch_assoc()) { $origItem = $row['comment_author']; $changedItem = strpos($origItem, ' -1 ? substr($origItem, 9, -3) : $origItem; print "Current Author: " . htmlentities($origItem); if ($origItem == $changedItem) { print " | No Change "; } else { print " | Trying to Change To: " . $changedItem; print "... "; $stmt = $link->prepare("UPDATE wp_comments SET comment_author = ? WHERE comment_id = ?"); $stmt->bind_param("si", $changedItem, $row['comment_id']); if ($isTest ) { print "Not Updated - "; print "Test Only Mode Activated
\n"; } else { if (! $stmt->execute() ) { print "Failed - "; printf("Errormessage: %s\n", $link->error). "
\n"; $stmt->close(); $results->close(); $link->close(); exit(); } print "Success!
\n"; } $stmt->close(); } } $results->close(); $link->close(); echo "
\n"; } function print_tool_header($title = 'Wordpress Import Fix Tool', $message = '') { $blog_name = get_bloginfo('name'); $blog_url= get_bloginfo('wpurl'); $blog_lang = language_attributes(); $blog_html= get_bloginfo('html_type'); $blog_charset= get_bloginfo('charset'); $blog_version = get_bloginfo('version'); $blog_rtl = ""; $blog_header = wptexturize($blog_name) .'  (View Site)'; if ( ('rtl' == $wp_locale->text_direction) ) : $blog_rtl = << EOT; endif; echo $text = << {$blog_name} › {$title}
EOT; } // End of print_tool_header() function close_html() { echo $text = << EOT; } function print_confirmation() { echo $text = <<Running Fix

ARE YOU SURE YOU WISH TO DO THIS?

Fixes to be applied:
  • Fix <![CDATA[    ]]> in comment author fields
Modications to your database cannot be undone. Please run the script in "Test Mode" first to confirm the changes that will be made.


 

EOT; } function print_startpage() { echo $text = <<Wordpress Export/Import Fixer
Fixes to be applied:
  • Fix <![CDATA[    ]]> in comment author fields

It is recommended that you run the script in "Test Mode" first to review the changes that will be made. In "Test Mode", no actual changes will be made to the database. Once you choose "Apply Fixes" the database will be modified and this cannot be undone.

EOT; } switch ($action) { case 'testall' : print_tool_header(); update_names('testonly'); close_html(); break; case 'runall' : print_tool_header(); if ('true' == $_REQUEST['confirm'] ) { update_names(); } else { print_confirmation(); } close_html(); break; default: print_tool_header(); print_startpage(); close_html(); break; } ?>