Mark as Inactive;delete->Delete From List;:inactivate";
$HELP_ITEMS["Handler"]["Title"] = "Remove Options";
$HELP_ITEMS["Handler"]["Content"] = "What would you like to happen to the list of email addresses? Choose \'Mark as Inactive\' to simply mark them as inactive but not to delete them. Choose \'Delete from List\' to remove them from the mailing list completely.";
$FORM_ITEMS[$FORM_REQUIRED_ITEM . "Remove Emails"]="textarea|RemoveEmail:30:5:";
$HELP_ITEMS["RemoveEmail"]["Title"] = "Remove Emails";
$HELP_ITEMS["RemoveEmail"]["Content"] = "Enter the list of emails that you wish to remove here. You should put each email address on a new line.
Use this option if you have a small number of email addresses to remove.";
$FORM_ITEMS[$FORM_REQUIRED_ITEM . "Remove File"]="file|TextFileName";
$HELP_ITEMS['TextFileName']['Title'] = "Upload File";
$HELP_ITEMS['TextFileName']['Content'] = "Choose a file to upload that contains the subscriber details that you want to remove. This should be a plain text file.
Use this option if you have a large number of email addresses to remove.";
$FORM_ITEMS["-1"]="submit|Next »:1-remsub";
$FORM=new AdminForm;
$FORM->title="RemoveOptions";
$FORM->items=$FORM_ITEMS;
$FORM->action=MakeAdminLink("remsub?Action=Remove&ListID=".$ListID);
$FORM->MakeForm("Remove Subscribers");
$FORM->output = "Choose the options to use to remove subscribers from the mailing list." . $FORM->output;
$OUTPUT = MakeBox("Remove Subscribers (Step 2 of 3)",$FORM->output);
$OUTPUT .= '
';
}
if ($Action == 'Remove') {
$subaction = $_POST['Handler'];
if (trim($_POST['RemoveEmail']) != '') {
$SuccessfulRemoves = $UnsuccessfulRemoves = $Errors = 0;
$email_addresses = explode("\r\n", $_POST['RemoveEmail']);
foreach($email_addresses as $email) {
$qry = "SELECT * FROM " . $TABLEPREFIX . "members WHERE Email='" . addslashes($email) . "' AND ListID='" . addslashes($ListID) . "'";
$member_result = mysql_query($qry);
if (mysql_num_rows($member_result) < 1) {
$UnsuccessfulRemoves++;
continue;
}
if (mysql_num_rows($member_result) > 1) {
$Errors++;
continue;
}
$member = mysql_fetch_assoc($member_result);
$memberid = $member['MemberID'];
$queries = array();
if ($_POST['Handler'] == 'delete') {
$qry = "DELETE FROM " . $TABLEPREFIX . "members WHERE MemberID='" . addslashes($memberid) . "' AND ListID='" . addslashes($ListID) . "'";
$queries[] = $qry;
$qry = "DELETE FROM " . $TABLEPREFIX . "list_field_values WHERE UserID='" . addslashes($memberid) . "' AND ListID='" . addslashes($ListID) . "'";
$queries[] = $qry;
} else {
$qry = "UPDATE " . $TABLEPREFIX . "members SET Status='0' WHERE MemberID='" . addslashes($memberid) . "' AND ListID='" . addslashes($ListID) . "'";
$queries[] = $qry;
}
foreach($queries as $qry) {
mysql_query($qry);
}
$SuccessfulRemoves++;
}
$Action = 'Finished';
} else {
if (!empty($_FILES['TextFileName'])) {
$userfile = $_FILES['TextFileName']['tmp_name'];
$filename = $_FILES['TextFileName']['name'];
if(is_file($userfile)) {
if(!is_writable($ROOTDIR.'/temp')) {
$OUTPUT .= MakeErrorBox("An error occurred", "The '" . $ROOTDIR . "temp' folder is not writable. Please CHMOD this folder to 757.");
} else {
clearstatcache();
$remfile = $ROOTDIR.'/temp/remove_addresses';
move_uploaded_file($userfile, $remfile);
}
$REMOVE_DIR = $ROOTDIR.'temp/remove_temp';
$num_files = 0;
/*
This splits up the file to be imported into 100 line chunks so we can do a popup window and have it refresh.
This should ease people who are looking to import thousands of users at a time.
*/
if (!is_dir($REMOVE_DIR)) {
if (!mkdir($REMOVE_DIR, 0755)) {
$OUTPUT .= MakeErrorBox("An error occurred", "Unable to create directory " . str_replace($ROOTDIR, '', $REMOVE_DIR));
}
}
if (is_dir($REMOVE_DIR)) {
$original_remove_file = file($ROOTDIR.'temp/remove_addresses');
$size = sizeof($original_remove_file);
$num_files = 1;
$start_pos = 0;
while($start_pos < $size) {
$file_contents = array_slice($original_remove_file, $start_pos, $REMOVE_PER_FILE);
$handle = fopen($REMOVE_DIR.'/remove_file' . $num_files, 'w');
fputs($handle, implode("", $file_contents));
fclose($handle);
$start_pos += $REMOVE_PER_FILE;
$num_files++;
}
}
$popup_link = 'remsub?Action=DoRemoveSubscribers&TotalFiles='.$num_files.'&StartTime='.$SYSTEMTIME.'&ListID=' . $ListID . '&Handler=' . $_POST['Handler'];
$OUTPUT = MakeSuccessBox("File Uploaded Successfully", "Click OK to start removing email addresses
", MakeAdminLink($popup_link), "", "", "remove~width=300,height=400,left=400,top=300");
} else {
$OUTPUT = MakeErrorBox("Invalid Import File", "The file you selected to import from doesn't exist");
}
}
}
}
if ($Action == 'DoRemoveSubscribers') {
$OUTPUT = '