1<?php 2require_once dirname(__FILE__).'/accesscheck.php'; 3 4@ob_end_flush(); 5flushBrowser(); 6 7if (!$_SESSION['logindetails']['superuser']) { 8 echo $GLOBALS['I18N']->get('Sorry, this page can only be used by super admins'); 9 10 return; 11} 12 13if (isset($_POST['unsubscribe'])) { 14 $emails = explode("\n", trim($_POST['unsubscribe'])); 15 $total = count($emails); 16 $count = $notfound = $deleted = $blacklisted = $notDeleted = 0; 17 foreach ($emails as $email) { 18 $email = trim($email); 19 ++$count; 20 set_time_limit(600); 21 $userid = Sql_Fetch_Row_Query(sprintf('select id from %s where email = "%s"', $GLOBALS['tables']['user'], 22 $email)); 23 if (!empty($_POST['blacklist'])) { 24 ++$blacklisted; 25 addUserToBlackList($email, 26 $GLOBALS['I18N']->get('Blacklisted by').' '.$_SESSION['logindetails']['adminname']); 27 } 28 $campaignCount = Sql_Fetch_Row_Query(sprintf('select count(*) from %s where userid = %d', 29 $GLOBALS['tables']['usermessage'], $userid[0])); 30 31 if ($userid[0] && empty($campaignCount[0])) { 32 deleteUser($userid[0]); 33 ++$deleted; 34 } elseif (!empty($campaignCount[0])) { 35 ++$notDeleted; 36 } else { 37 ++$notfound; 38 } 39 if ($total > 100) { 40 if ($count % 100 == 0) { 41 printf('%d/%d<br/>', $count, $total); 42 flushBrowser(); 43 } 44 } 45 } 46 echo s('All done, %d emails processed<br/>%d emails blacklisted<br/>%d emails deleted<br/>%d emails not found', 47 $count, $blacklisted, $deleted, $notfound); 48 echo '<br/>'.s('%d subscribers could not be deleted, because they have already received campaigns', $notDeleted); 49 echo '<br/>'.PageLinkButton('massremove', s('Remove more')); 50 51 return; 52} 53?> 54 55<form method=post action=""> 56 <h3><?php echo $GLOBALS['I18N']->get('Mass remove email addresses') ?></h3> 57 58 <?php echo $GLOBALS['I18N']->get('Check to also add the emails to the blacklist') ?> <input type="checkbox" 59 name="blacklist" 60 value="1"><br/> 61 <p class="information"><?php echo $GLOBALS['I18N']->get('Paste the emails to remove in this box, and click continue') ?></p> 62 <p class="submit"><input type="submit" name="go" value="<?php echo $GLOBALS['I18N']->get('Continue') ?>"></p><br/> 63 <textarea name="unsubscribe" rows=30 cols=40></textarea> 64</form> 65