Here's the script I made/used to go from
Marco's name change mod to this one.
PHP Code:
<?php
// Change this stuff
$dbhost = 'host';
$dbuser = 'user';
$dbpass = 'pass';
$dbname = 'table';
// END OF STUFF TO CHANGE
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if($mysqli->connect_error) {
die("Connect Error: " . $mysqli->connect_error);
}
// Get current usernames for users that have changes
$result = $mysqli->query("SELECT distinct mh_unm_history.userid, user.username FROM mh_unm_history, user WHERE user.userid = mh_unm_history.userid");
while ($row = $result->fetch_row()) {
$usernames[$row[0]] = mysql_real_escape_string($row[1]);
}
$result->free_result();
// Get the username changes
$result = $mysqli->query("SELECT * from mh_unm_history ORDER BY userid ASC, dateline DESC");
while ($row = $result->fetch_row()) {
$userid = $row[0];
$dateline = $row[1];
$oldname = mysql_real_escape_string($row[2]);
$adminid = $row[3];
$uniq = md5($dateline . $userid . $userid . rand(1111,9999));
// Build the array of queries we'll execute later
$q[] = "INSERT INTO userchangelog VALUES('', $userid, 'username', '$usernames[$userid]', '$oldname', $adminid, $dateline, '$uniq')";
// Set the username as the old one in the
// event there are multiple name changes
$usernames[$userid] = $oldname;
}
foreach ($q as $query) {
if (!$mysqli->real_query($query))
echo "FAILED: " . $query . "<br>\n";
}
$result->close();
$mysqli->close();
?>
Things I know will cause issues: if you don't have the mysqli (notice the i) extension or use a prefix on your forum tables.
You're on your own to backup/test/verify/etc the above code will work for you!