Copy the code below into a new file, e.g.: codespecial.php and upload it to your main ListMail folder. Login to ListMail, then modify the URL in the address bar to browse to the custom script.
You'll be presented with a dropdown showing all of your links. Choose the link you want to process and hit "Create List". All users on all lists who have clicked this link will be moved to a new list (created with a List Name the same as the Link's Title). If you run the process twice on the same link there will be a new list again with all users from all lists, so the OLD new list will still exist but have no users.
<?php// process specified link code// create a new list with all users who clicked code// ** Be sure to place this script IN your ListMail directory// v1.8 Note: List is configured with the Default HTML and Error Messagesinclude("./config.php");include("./admin.php");$islogged = islogged();ini_set("max_execution_time","0");if($islogged){$isadmin='true';} else { adminheader('Not logged in','Not logged in','x');echo "<center>You must <a href=login.php>login</a>."; exit; }if ($isadmin == 'true'){$link = mysql_connect($sqlhost,$sqluser,$sqlpass);mysql_selectdb($sqldb);if($_POST['submit']=='Copy'){ $copy = 1; $move = ''; $append = '';}if($_POST['submit']=='Move'){ $copy = ''; $move = 1; $append = '';}if($_POST['submit']=='Append'){ $copy = ''; $move = ''; $append = 1; }if($move) $txt = 'moved'; elseif($copy) $txt = 'copied'; elseif($append) $txt = 'appended';echo "<a href=./>Back to ListMail</a><br><br>";if($process_link){ // create new list with link ref code (if doesn't exist) list($kref)=mysql_fetch_row(mysql_query("select refcode from $ktable where id = '".addslashes($process_link)."'")); if($append){ $newlist = $list; echo "Target "; } else { $newlist = new_list($kref); echo "New "; } echo "list num = $newlist<br>"; // get user hits for this link $cmd = "select uid from lm_hits where kid = '".addslashes($process_link)."' group by uid"; $rows = mysql_query($cmd); echo "new list: $newlist<br>$txt users: "; if(@mysql_num_rows($rows)>0){ while(list($uid)=mysql_fetch_row($rows)){ if($move){ // update the user with the new list mysql_query("update lm_users set list = '$newlist' where id = '".addslashes($uid)."'"); } elseif($copy || $append){ // get all user data and create a new user on the new list list($fn,$ln,$em,$u1,$u2,$u3,$u4,$u5,$u6,$u7,$u8,$u9,$u10,$cn,$da,$ip,$ru,$htm)=mysql_fetch_row(mysql_query("select fname,lname,email,user1,user2,user3,user4,user5,user6,user7,user8,user9,user10,cnf,dateadd,ipaddr,refurl,htmail from lm_users where id = '".addslashes($uid)."';")); // create new uid $uniq = ''; while(!$uniq){ $newuid = unique_id(7); if(@mysql_num_rows(mysql_query("select id from $utable where uid = '$newuid'"))==0) $uniq=1; } // insert user if not already on new list $trow = mysql_query("select id from lm_users where email like '$em' and list = '$newlist'"); if(@mysql_num_rows($trow)==0){ mysql_query("insert into lm_users values('','$newuid','$newlist','".addslashes($fn)."','".addslashes($ln)."','".addslashes($em)."','".addslashes($u1)."','".addslashes($u2)."','".addslashes($u3)."','".addslashes($u4)."','".addslashes($u5)."','".addslashes($u6)."','".addslashes($u7)."','".addslashes($u8)."','".addslashes($u9)."','".addslashes($u10)."','1','','$cn','".addslashes($da)."','".addslashes($ip)."','".addslashes($ru)."','".addslashes($htm)."','0');") or die('user insert error..'.mysql_error()); } else { echo "skip"; } } echo "$uid "; flush(); } } else echo "process aborted: no tracked users found for selected link<br>"; echo "<br><br>";}// show all links$cmd = "select id,refcode,title,http,hits from $ktable where 1 order by refcode";$rows = mysql_query($cmd);echo "This script will create a new list containing all users from any list who have clicked through a certain link. Users can be copied or moved from their old list.<br><br>";if(@mysql_num_rows($rows)>0){ echo " Select link to process:<br><br><form method=post><input type=hidden name=process value=1><select name=process_link>"; while(list($i,$r,$t,$h,$s)=mysql_fetch_row($rows)){ echo "<option value=$i>$r - $h"; } echo "</select><br><br><input name=submit type=submit value=\"Move\"> <input name=submit type=submit value=\"Copy\"> or <input name=submit type=submit value=\"Append\"> to <select name=list>\n"; $lrows = mysql_query("select listnum,title from $ltable where 1 order by listnum"); while(list($li,$ti)=mysql_fetch_row($lrows)){ echo "<option value=$li>$li: $ti\n"; } echo "</select></form>";} else echo "no links found!<br>";}function new_list($refcode){ global $link; global $ltable; global $vtable; $cmd = "select id,listnum from $ltable where title like '".addslashes($refcode)."' limit 1"; $result = mysql_query($cmd); if(@mysql_num_rows($result)>0){ list($id,$nlnum)=mysql_fetch_row($result); } else { $cmd = "select id,listnum from $ltable where id >= '0' order by listnum desc limit 0,1"; $result = mysql_query($cmd); while(list($id,$listnum) = @mysql_fetch_row($result)){ $nlnum = $listnum+1; $xmails = explode(';',$adminmail); $adminmail = $xmails[0]; $dom = getdomain(); $cmd2 = "insert into $ltable values('null','$nlnum','".addslashes($refcode)."','news@$dom','New List Newsletter','Welcome!','Welcome to the mailing list!','','','1','Please verify your subscription','Click the link below to verify your email address for subscription to the yoursite.com newsletter\n\n!confirm','','','0','remsubj','remmsg','','','','','','', '','','','','','','','','','','0;0;0;0;0','$adminmail','0;1','1','1','')"; mysql_query($cmd2) or die('list creation error: '.mysql_error()); } } return $nlnum;}?>