diff --git a/public_html/lists/admin/mergeduplicates.php b/public_html/lists/admin/mergeduplicates.php index d83fa5648..e64073cbe 100644 --- a/public_html/lists/admin/mergeduplicates.php +++ b/public_html/lists/admin/mergeduplicates.php @@ -48,43 +48,43 @@ function mergeUsers($original, $duplicate) echo '

Add HEX column

'; //# add a hex column on email, for better indexing -Sql_Query('alter table phplist_user_user add column hexemail varchar(255) not null default ""'); -Sql_Query('alter table phplist_user_user add index hexemailidx (hexemail)'); -Sql_Query('update phplist_user_user set hexemail = hex(email)'); +Sql_Query(sprintf('alter table %s add column hexemail varchar(255) not null default ""', $GLOBALS['tables']['user'])); +Sql_Query(sprintf('alter table %s add index hexemailidx (hexemail)', $GLOBALS['tables']['user'])); +Sql_Query(sprintf('update %s set hexemail = hex(email)', $GLOBALS['tables']['user'])); echo '

Add HEX Test column

'; //# add another column for the test value -Sql_Query('alter table phplist_user_user add column hexemailtest varchar(255) not null default ""'); -Sql_Query('alter table phplist_user_user add index hexemailtestidx (hexemailtest)'); -Sql_Query('update phplist_user_user set hexemailtest = concat(hexemail,"0D")'); +Sql_Query(sprintf('alter table %s add column hexemailtest varchar(255) not null default ""', $GLOBALS['tables']['user'])); +Sql_Query(sprintf('alter table %s add index hexemailtestidx (hexemailtest)', $GLOBALS['tables']['user'])); +Sql_Query(sprintf('update %s set hexemailtest = concat(hexemail,"0D")', $GLOBALS['tables']['user'])); //# this should render no results //select u1.id,u2.id,hex(u1.email),hex(u2.email) from phplist_user_user u1 left join phplist_user_user u2 on u1.hexemail = u2.hexemail where u1.id != u2.id; // find the ones that match on email with 0D added (\r -> carriage return) echo '

Merge on CR

'; -$req = Sql_Verbose_Query('select u1.id,u2.id from phplist_user_user u1 - left join phplist_user_user u2 on u1.hexemailtest = u2.hexemail where u1.id != u2.id'); +$req = Sql_Verbose_Query(sprintf('select u1.id,u2.id from %s u1 + left join %s u2 on u1.hexemailtest = u2.hexemail where u1.id != u2.id', $GLOBALS['tables']['user'], $GLOBALS['tables']['user'])); while ($row = Sql_Fetch_Row($req)) { mergeUsers($row[0], $row[1]); } echo '

Merge on NL

'; // find the ones that match on email with 0A added (\n -> newline) -Sql_Query('update phplist_user_user set hexemailtest = concat(hexemail,"0A")'); -$req = Sql_Verbose_Query('select u1.id,u2.id from phplist_user_user u1 - left join phplist_user_user u2 on u1.hexemailtest = u2.hexemail where u1.id != u2.id'); +Sql_Query(sprintf('update %s set hexemailtest = concat(hexemail,"0A")', $GLOBALS['tables']['user'])); +$req = Sql_Verbose_Query(sprintf('select u1.id,u2.id from %s u1 + left join %s u2 on u1.hexemailtest = u2.hexemail where u1.id != u2.id', $GLOBALS['tables']['user'], $GLOBALS['tables']['user'])); while ($row = Sql_Fetch_Row($req)) { mergeUsers($row[0], $row[1]); } echo '

Merge on TAB

'; // find the ones that match on email with 09 added (\t -> tab) -Sql_Query('update phplist_user_user set hexemailtest = concat(hexemail,"09")'); -$req = Sql_Verbose_Query('select u1.id,u2.id from phplist_user_user u1 - left join phplist_user_user u2 on u1.hexemailtest = u2.hexemail where u1.id != u2.id'); +Sql_Query(sprintf('update %s set hexemailtest = concat(hexemail,"09")', $GLOBALS['tables']['user'])); +$req = Sql_Verbose_Query(sprintf('select u1.id,u2.id from %s u1 + left join %s u2 on u1.hexemailtest = u2.hexemail where u1.id != u2.id', $GLOBALS['tables']['user'], $GLOBALS['tables']['user'])); while ($row = Sql_Fetch_Row($req)) { mergeUsers($row[0], $row[1]); } -Sql_Query('alter table phplist_user_user drop index hexemailidx, drop index hexemailtestidx, drop column hexemail, drop column hexemailtest'); +Sql_Query(sprintf('alter table %s drop index hexemailidx, drop index hexemailtestidx, drop column hexemail, drop column hexemailtest', $GLOBALS['tables']['user']));