Author Topic: Copy list  (Read 1762 times)

a-goodwin

  • Posts: 23
    • View Profile
Copy list
« on: September 10, 2006, 01:29:57 am »
Hello:  I accidentally erased my main list with everyone in it.  But I have them in smaller sub lists.  How do I get all of those names from the sub lists back into the main list?

Thanks

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Copy list
« Reply #1 on: September 10, 2006, 03:58:23 am »
This is not an easy task, and all of your users will be created with a new UID so old remove links and tracking will no longer work.

Until I release the next update, where you can copy "all results" (ie. an entire list) from the User Database page, it will take a custom script...

Okay, here it is! :D Copy and paste the code below into a new .php file, upload it to your ListMail folder and browse to it once.
Code: [Select]
<?php// copy all active users from all lists to one list, eliminating dupes// TO list$list = '1';// SCRIPTecho "copying, please wait...<br>"; flush();include('./config.php');include('./admin.php');$t=0; // counter// loop all lists$rows = mysql_query("select listnum from $ltable where listnum <> '$list';");while(list($xlist)=mysql_fetch_row($rows)){ // loop all users $urows = mysql_query("select * from $utable where list = '$xlist' and cnf = '1';"); while(list($id,$uid,$ul,$fn,$ln,$em,$u1,$u2,$u3,$u4,$u5,$u6,$u7,$u8,$u9,$u10,$seq,$del,$cnf,$da,$ip,$ru,$ht,$bo)=mysql_fetch_row($urows)){  // check target dupe  list($cnt)=mysql_fetch_row(mysql_query("select count(*) from $utable where list = '$list' and email like '$em';"));  if($cnt==0){   // create unique id and insert user   $uniq = '';   while(!$uniq){    $uniq_str = unique_id(7);    if(@mysql_num_rows(mysql_query("select id from $utable where uid = '$uniq_str'"))==0) $uniq=1;   }   $cmd = "insert into $utable values ('','$uniq_str','$list','".addslashes($fn)."','".addslashes($ln)."','$em','".addslashes($u1)."','".addslashes($u2)."','".addslashes($u3)."','".addslashes($u4)."','".addslashes($u5)."','".addslashes($u6)."','".addslashes($u7)."','".addslashes($u8)."','".addslashes($u9)."','".addslashes($u10)."','".addslashes($seq)."','".addslashes($del)."','1','$da','".addslashes($ip)."','".addslashes($ru)."','$ht','0')";   mysql_query($cmd);   $t++;  } // else do nothing }}echo "done!<br>$t users copied.";?>

Other than for syntax this is untested and you run it at your own risk. :)  Make a backup first!

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting