Backup Your Mailman Email Lists!" . "
USE AT YOUR OWN RISK.
". "This script will backup all of your email addresses with names from Mailman ". "subscription lists, even for lists large enough to span multiple pages. It has been tested on Mailman version 2.1.5.
". "
". "This script is provided courtesy of www.thepeters.org with contributions by Craig Norberg-Bohm to make it work with larger lists.
". "For BEST SECURITY, put this script into YOUR OWN php installation and run it OR CHANGE YOUR PASSWORD RIGHT AFTER YOU RUN THIS. I am in a shared hosting environment and have little control over security, including someone hacking this script.
"; echo "\n"; } else { $mailmanUrl =$_POST['url']; $theurl = $mailmanUrl."members?adminpw=".$listPassword; $numemails=0; // // Get the list of member letter pages // echo "\n";
echo "\n\n\n";
if (!($fp = fopen($theurl, 'r')))
{
echo 'could not open url';
exit;
}
$contents = '';
while (!feof($fp)) {
$contents .= fread($fp, 8192);
}
fclose($fp);
// echo $contents;
//
// put each segment in its own string
//
$lines = explode("members?letter=",$contents);
//
// iterate through lines and glean letter=
//
// cnb: add iteration to include chunks above 0, et 1, 2 etc.
// chunks are empty when _realname is not longer found in the page
//
//
$i = 2; // ignore first two segments as they are extraneous
while (isset($lines[$i]) && $lines[$i]!="") {
// echo substr($lines[$i++],0,1)."\n";
$letter = substr($lines[$i++],0,1);
// fetch first for chunk 0, then 1, 2 until empty
$chunknum = 0;
$chunking = TRUE; // indicates we are chunking
while ($chunking) {
$letterUrl = $mailmanUrl."members?letter=".$letter."&adminpw=".$listPassword."&chunk=".$chunknum;
echo "\n\n\n";
//
// Fetch the letter page - yes, this should be a subroutine, but oh well
//
if (!($lfp = fopen($letterUrl, 'r')))
{
echo 'could not open url';
$chunking=FALSE;
exit;
}
$letterContents = '';
while (!feof($lfp)) {
$letterContents .= fread($lfp, 8192);
}
fclose($lfp);
//
// Parse to get email addresses
// todo - make it parse and output each line as "firstname lastname
";
//echo $emailaddr[0]."
";
$j++;
$numemails++;
} // parsing page
$chunknum++;
} // for each chunk
}
echo "
Number of email addresses in this list = ".$numemails."
\n"; } // end of else ?>