After learning that disabling an account does not work:
viewtopic.php?t=17764&highlight=disable
and being overwhelmed by a solution that might have worked but seemed too technical for my feeble mind:
viewtopic.php?t=5009
and trying another that seemed simple but didn't work for me:
viewtopic.php?p=45860#45860
I decided to mash-up some code and hack my own solution.
It seems to work, but I can imagine that there would be any number of reasons why it's a bad solution, and was curious to hear them... or if it's acceptable, to let others use it as well.
by-the-by, this seems to be a recurring request, so I'd ad my voice to those that would love a built-in solution to this in phplist. It'd make transition to phplist much easier for me!
Here is what I did:
1) put each email to blacklist on it's own line in a file called "blacklist.txt" and saved it into the root install directory of phplist
2) copied the code below into a file (i called it "massblacklist.php"), also in the root install directory of phplist
3) brought up massblacklist.php in a browser.
4) Check to see if it worked... that's it.
NOTE: for some reason, it seems to take a bit of time for the info to update in the phplist admin interface? shows up ok in phpmyadmin. not tested extensively, but I think it works.. here is the code:
- Code: Select all
<?php
//here is the file with the blacklist emails
$emailfile="blacklist.txt";
//here is a bunch of stuff from the index file
//I know you need some of it, but perhaps not all...
ob_start();
$er = error_reporting(0);
require_once dirname(__FILE__) .'/admin/commonlib/lib/magic_quotes.php';
require_once dirname(__FILE__).'/admin/init.php';
## none of our parameters can contain html for now
$_GET = removeXss($_GET);
$_POST = removeXss($_POST);
$_REQUEST = removeXss($_REQUEST);
if (isset($_SERVER["ConfigFile"]) && is_file($_SERVER["ConfigFile"])) {
# print '<using>'."\n";
include $_SERVER["ConfigFile"];
} elseif (isset($_ENV["CONFIG"]) && is_file($_ENV["CONFIG"])) {
# print '<using>'."\n";
include $_ENV["CONFIG"];
} elseif (is_file("config/config.php")) {
# print '<using>'."\n";
include "config/config.php";
} else {
print "Error, cannot find config file\n";
exit;
}
if (0) {#isset($GLOBALS["developer_email"]) && $GLOBALS['show_dev_errors']) {
error_reporting(E_ALL);
} else {
if (isset($error_level)) {
error_reporting($error_level);
} else {
error_reporting($er);
}
}
require_once dirname(__FILE__).'/admin/'.$GLOBALS["database_module"];
require_once dirname(__FILE__)."/texts/english.inc";
include_once dirname(__FILE__)."/texts/".$GLOBALS["language_module"];
require_once dirname(__FILE__)."/admin/defaultconfig.inc";
require_once dirname(__FILE__).'/admin/connect.php';
include_once dirname(__FILE__)."/admin/languages.php";
include_once dirname(__FILE__)."/admin/lib.php";
$I18N= new phplist_I18N();
if ($require_login || ASKFORPASSWORD) {
# we need session info if an admin subscribes a user
if (!empty($GLOBALS["SessionTableName"])) {
require_once dirname(__FILE__).'/admin/sessionlib.php';
}
@session_start(); # it may have been started already in languages
}
if (!isset($_POST) && isset($HTTP_POST_VARS)) {
require "admin/commonlib/lib/oldphp_vars.php";
}
/*
We request you retain the inclusion of pagetop below. This will add invisible
additional information to your public pages.
This not only gives respect to the large amount of time given freely
by the developers but also helps build interest, traffic and use of
PHPlist, which is beneficial to it's future development.
Michiel Dethmers, Tincan Ltd 2000,2006
*/
include "admin/pagetop.php";
if (isset($_GET['id'])) {
$id = sprintf('%d',$_GET['id']);
} else {
$id = 0;
}
//here is the hacked stuff for blacklisting
//it is mostly taken from the links listed in my post
echo '<html>';
echo 'phplistadd running <br><br>';
require_once dirname(__FILE__) .'/admin/commonlib/lib/userlib.php';
//init
$emails= array();
$attributes=NULL;
$rownum=0;
// open file and loop, processing each line in turn
$fh = fopen($emailfile, 'r');
echo "file opened";
if ($fh)
{
while (!feof($fh))
{
$theline = fgets($fh);
$emails[$rownum] = trim($theline);
echo $emails[$rownum];
addUserToBlackList($emails[$rownum], 'Admin Blacklisted');
echo " yep - blacklisted: ".$emails[$rownum]."<br>";
++$rownum;
}
$count = 0;
return;
}
else
{
echo 'Failed to open file "' . $emailfile . '".<br>';
}
// done
?>