function unsubscribePage($id) { global $tables; $email = ''; $userid = 0; $msg = ''; ## for unsubscribe, don't validate host $GLOBALS['check_for_host'] = 0; $res = '<title>' . $GLOBALS['strUnsubscribeTitle'] . '</title>' . "\n"; $res .= $GLOBALS['pagedata']['header']; if (isset($_GET['uid'])) { $userdata = Sql_Fetch_Array_Query(sprintf('select email,id,blacklisted from %s where uniqid = "%s"', $tables['user'], sql_escape($_GET['uid']))); $email = $userdata['email']; $userid = $userdata['id']; $isBlackListed = $userdata['blacklisted'] != '0'; $blacklistRequest = false; } else { if (isset($_REQUEST['email'])) { $email = $_REQUEST['email']; } if (!validateEmail($email)) { $email = ''; } #0013076: Blacklisting posibility for unknown users # Set flag for blacklisting $blacklistRequest = $_GET['p'] == 'blacklist' || $_GET['p'] == 'donotsend'; # only proceed when user has confirm the form if ($blacklistRequest && is_email($email)) { $_POST['unsubscribe'] = 1; $_POST['unsubscribereason'] = s('Forwarded receiver requested blacklist'); } } if (UNSUBSCRIBE_JUMPOFF || !empty($_GET['jo'])) { $_POST['unsubscribe'] = 1; $_REQUEST['email'] = $email; if (!empty($_GET['jo'])) { $blacklistRequest = true; $_POST['unsubscribereason'] = s('"Jump off" used by subscriber, reason not requested'); } else { $_POST['unsubscribereason'] = s('"Jump off" set, reason not requested'); } } foreach ($GLOBALS['plugins'] as $pluginname => $plugin) { # print $pluginname.'<br/>'; if ($plugin->unsubscribePage($email)) { return; } } if (!empty($email) && isset($_POST['unsubscribe']) && isset($_REQUEST['email']) && isset($_POST['unsubscribereason'])) { ## all conditions met, do the unsubscribe #0013076: Blacklisting posibility for unknown users // It would be better to do this above, where the email is set for the other cases. // But to prevent vulnerabilities let's keep it here for now. [bas] if (!$blacklistRequest) { $query = Sql_Fetch_Row_Query(sprintf('select id,email,blacklisted from %s where email = "%s"', $tables['user'], sql_escape($email))); $userid = $query[0]; $email = $query[1]; $isBlackListed = !empty($query[2]); } if (!$userid) { #0013076: Blacklisting posibility for unknown users if ($blacklistRequest && !empty($email)) { addUserToBlacklist($email, $_POST['unsubscribereason']); addSubscriberStatistics('blacklist', 1); $res .= '<h3>' . $GLOBALS['strUnsubscribedNoConfirm'] . '</h3>'; } else { $res .= $GLOBALS['strNoListsFound']; #'Error: '.$GLOBALS["strUserNotFound"]; logEvent('Request to unsubscribe non-existent user: '******'select listid from %s where userid = %d', $GLOBALS['tables']['listuser'], $userid)); while ($row = Sql_Fetch_Row($listsreq)) { array_push($subscriptions, $row[0]); } ## 17753 - do not actually remove the list-membership when unsubscribing # $result = Sql_query(sprintf('delete from %s where userid = %d',$tables["listuser"],$userid)); $lists = ' * ' . $GLOBALS['strAllMailinglists'] . "\n"; if (empty($isBlackListed)) { // only process when not already marked as blacklisted # add user to blacklist addUserToBlacklist($email, nl2br(strip_tags($_POST['unsubscribereason']))); addUserHistory($email, 'Unsubscription', "Unsubscribed from {$lists}"); $unsubscribemessage = str_replace('[LISTS]', $lists, getUserConfig("unsubscribemessage:{$id}", $userid)); sendMail($email, getUserConfig("unsubscribesubject:{$id}"), stripslashes($unsubscribemessage), system_messageheaders($email), '', true); $reason = $_POST['unsubscribereason'] ? "Reason given:\n" . stripslashes($_POST['unsubscribereason']) : 'No Reason given'; sendAdminCopy('List unsubscription', $email . " has unsubscribed\n{$reason}", $subscriptions); addSubscriberStatistics('unsubscription', 1); } } if ($userid) { $res .= '<h3>' . $GLOBALS['strUnsubscribeDone'] . '</h3>'; } #0013076: Blacklisting posibility for unknown users //if ($blacklistRequest) { //$res .= '<h3>'.$GLOBALS["strYouAreBlacklisted"] ."</h3>"; //} $res .= $GLOBALS['PoweredBy'] . '</p>'; $res .= $GLOBALS['pagedata']['footer']; return $res; } elseif (isset($_POST['unsubscribe']) && !is_email($email) && !empty($email)) { $msg = '<span class="error">' . $GLOBALS['strEnterEmail'] . '</span><br>'; } $res .= '<h3>' . $GLOBALS['strUnsubscribeInfo'] . '</h3>' . $msg . '<form method="post" action=""><input type="hidden" name="p" value="unsubscribe" />'; if (!isset($_POST['email']) || empty($email)) { $res .= '<p>' . $GLOBALS['strEnterEmail'] . ': <input type="text" name="email" value="' . $email . '" size="40" /></p>'; } else { $res .= '<p><input type="hidden" name="email" value="' . $email . '" />' . $GLOBALS['strEmail'] . ': ' . $email . '</p>'; } if (!$email) { $res .= '<input type="submit" name="unsubscribe" value="' . $GLOBALS['strContinue'] . '"></form>'; $res .= $GLOBALS['PoweredBy']; $res .= $GLOBALS['pagedata']['footer']; return $res; } $current = Sql_Fetch_Array_query(sprintf('select list.id as listid,user.uniqid as userhash, user.password as password from %s as list,%s as listuser,%s as user where list.id = listuser.listid and user.id = listuser.userid and user.email = "%s"', $tables['list'], $tables['listuser'], $tables['user'], sql_escape($email))); $some = $current['listid']; if (ASKFORPASSWORD && !empty($user['password'])) { # it is safe to link to the preferences page, because it will still ask for # a password $hash = $current['userhash']; } elseif (isset($_GET['uid']) && $_GET['uid'] == $current['userhash']) { # they got to this page from a link in an email $hash = $current['userhash']; } else { $hash = ''; } $finaltext = $GLOBALS['strUnsubscribeFinalInfo']; $pref_url = getConfig('preferencesurl'); $sep = strpos($pref_url, '?') !== false ? '&' : '?'; $finaltext = str_ireplace('[preferencesurl]', $pref_url . $sep . 'uid=' . $hash, $finaltext); if (!$some) { #0013076: Blacklisting posibility for unknown users if (!$blacklistRequest) { $res .= '<b>' . $GLOBALS['strNoListsFound'] . '</b></ul>'; } $res .= '<p><input type=submit value="' . $GLOBALS['strUnsubscribe'] . '">'; } else { if ($blacklistRequest) { $res .= $GLOBALS['strExplainBlacklist']; } elseif (!UNSUBSCRIBE_JUMPOFF) { list($r, $c) = explode(',', getConfig('textarea_dimensions')); if (!$r) { $r = 5; } if (!$c) { $c = 65; } $res .= $GLOBALS['strUnsubscribeRequestForReason']; $res .= sprintf('<br/><textarea name="unsubscribereason" cols="%d" rows="%d" wrap="virtual"></textarea>', $c, $r) . $finaltext; } $res .= '<p><input type=submit name="unsubscribe" value="' . $GLOBALS['strUnsubscribe'] . '"></p>'; } $res .= '</form>'; $res .= '<p>' . $GLOBALS['PoweredBy'] . '</p>'; $res .= $GLOBALS['pagedata']['footer']; return $res; }
$old_data = Sql_Fetch_Array_Query(sprintf('select * from %s where id = %d', $GLOBALS["tables"]["user"], $userid)); $old_data = array_merge($old_data, getUserAttributeValues('', $userid)); $history_entry = 'http://' . getConfig("website") . $GLOBALS["adminpages"] . '/?page=user&id=' . $userid . "\n\n"; if (ASKFORPASSWORD && $_POST["password"]) { if (ENCRYPTPASSWORD) { $newpassword = sprintf('%s', md5($_POST["password"])); } else { $newpassword = sprintf('%s', $_POST["password"]); } # see whether is has changed $curpwd = Sql_Fetch_Row_Query("select password from {$GLOBALS["tables"]["user"]} where id = {$userid}"); if ($_POST["password"] != $curpwd[0]) { $storepassword = '******' . $newpassword . '",'; Sql_query("update {$GLOBALS["tables"]["user"]} set passwordchanged = now() where id = {$userid}"); $history_entry .= "\nUser has changed their password\n"; addSubscriberStatistics('password change', 1); } else { $storepassword = ""; } } else { $storepassword = ""; } $rssfrequency = validateRssFrequency($_POST['rssfrequency']); $query = sprintf('update %s set email = "%s", %s htmlemail = %d, rssfrequency = "%s" where id = %d', $GLOBALS["tables"]["user"], addslashes($_POST["email"]), $storepassword, $_POST["htmlemail"], $rssfrequency, $userid); #print $query; $result = Sql_query($query); if ($data["email"] != $email) { $emailchanged = 1; Sql_Query(sprintf('update %s set confirmed = 0 where id = %d', $GLOBALS["tables"]["user"], $userid)); } # subscribe to the lists
function unsubscribePage($id) { $pagedata = pageData($id); if (isset($pagedata['language_file']) && is_file(dirname(__FILE__) . '/texts/' . $pagedata['language_file'])) { @(include dirname(__FILE__) . '/texts/' . $pagedata['language_file']); } global $tables; $res .= '<title>' . $GLOBALS["strUnsubscribeTitle"] . '</title>'; $res = $pagedata["header"]; if (isset($_GET["uid"])) { $req = Sql_Query("select * from {$tables['user']} where uniqid = \"" . $_GET["uid"] . "\""); $userdata = Sql_Fetch_Array($req); $email = $userdata["email"]; if (UNSUBSCRIBE_JUMPOFF) { $_POST["unsubscribe"] = 1; $_POST["email"] = $email; $_POST["unsubscribereason"] = '"Jump off" set, reason not requested'; } } if (isset($_POST["unsubscribe"]) && (isset($_POST["email"]) || isset($_POST["unsubscribeemail"])) && isset($_POST["unsubscribereason"])) { if (isset($_POST["email"])) { $email = trim($_POST["email"]); } else { $email = $_POST["unsubscribeemail"]; } $query = Sql_Fetch_Row_Query("select id,email from {$tables["user"]} where email = \"{$email}\""); $userid = $query[0]; $email = $query[1]; if (!$userid) { $res .= 'Error: ' . $GLOBALS["strUserNotFound"]; logEvent("Request to unsubscribe non-existent user: "******"email"], 0, 150)); } else { $result = Sql_query("delete from {$tables["listuser"]} where userid = \"{$userid}\""); $lists = " * " . $GLOBALS["strAllMailinglists"] . "\n"; # add user to blacklist addUserToBlacklist($email, nl2br(strip_tags($_POST['unsubscribereason']))); addUserHistory($email, "Unsubscription", "Unsubscribed from {$lists}"); $unsubscribemessage = ereg_replace("\\[LISTS\\]", $lists, getUserConfig("unsubscribemessage", $userid)); sendMail($email, getConfig("unsubscribesubject"), stripslashes($unsubscribemessage), system_messageheaders($email)); $reason = $_POST["unsubscribereason"] ? "Reason given:\n" . stripslashes($_POST["unsubscribereason"]) : "No Reason given"; sendAdminCopy("List unsubscription", $email . " has unsubscribed\n{$reason}"); addSubscriberStatistics('unsubscription', 1); } if ($userid) { $res .= '<h1>' . $GLOBALS["strUnsubscribeDone"] . "</h1><P>"; } $res .= $GLOBALS["PoweredBy"] . '</p>'; $res .= $pagedata["footer"]; return $res; } elseif (isset($_POST["unsubscribe"]) && !$_POST["unsubscribeemail"]) { $msg = '<span class="error">' . $GLOBALS["strEnterEmail"] . "</span><br>"; } elseif (!empty($_GET["email"])) { $email = trim($_GET["email"]); } else { if (isset($_REQUEST["email"])) { $email = $_REQUEST["email"]; } elseif (isset($_REQUEST['unsubscribeemail'])) { $email = $_REQUEST['unsubscribeemail']; } elseif (!isset($email)) { $email = ''; } } if (!isset($msg)) { $msg = ''; } $res .= '<b>' . $GLOBALS["strUnsubscribeInfo"] . '</b><br>' . $msg . formStart(); $res .= '<table> <tr><td>' . $GLOBALS["strEnterEmail"] . ':</td><td colspan=3><input type=text name="unsubscribeemail" value="' . $email . '" size=40></td></tr> </table>'; if (!$email) { $res .= "<input type=submit name=unsubscribe value=\"{$GLOBALS['strContinue']}\"></form>\n"; $res .= $GLOBALS["PoweredBy"]; $res .= $pagedata["footer"]; return $res; } $current = Sql_Fetch_Array_query("SELECT list.id as listid,user.uniqid as userhash, user.password as password FROM {$tables['list']} as list,{$tables['listuser']} as listuser,{$tables['user']} as user where list.id = listuser.listid and user.id = listuser.userid and user.email = \"{$email}\""); $some = $current["listid"]; if (ASKFORPASSWORD && !empty($user['password'])) { # it is safe to link to the preferences page, because it will still ask for # a password $hash = $current["userhash"]; } elseif (isset($_GET['uid']) && $_GET['uid'] == $current['userhash']) { # they got to this page from a link in an email $hash = $current['userhash']; } else { $hash = ''; } $finaltext = $GLOBALS["strUnsubscribeFinalInfo"]; $pref_url = getConfig("preferencesurl"); $sep = ereg('\\?', $pref_url) ? '&' : '?'; $finaltext = eregi_replace('\\[preferencesurl\\]', $pref_url . $sep . 'uid=' . $hash, $finaltext); if (!$some) { $res .= "<b>" . $GLOBALS["strNoListsFound"] . "</b></ul>"; $res .= '<p><input type=submit value="' . $GLOBALS["strResubmit"] . '">'; } else { list($r, $c) = explode(",", getConfig("textarea_dimensions")); if (!$r) { $r = 5; } if (!$c) { $c = 65; } $res .= $GLOBALS["strUnsubscribeRequestForReason"]; $res .= sprintf('<br/><textarea name="unsubscribereason" cols="%d" rows="%d" wrap="virtual"></textarea>', $c, $r) . ' ' . $finaltext . ' <p><input type=submit name="unsubscribe" value="' . $GLOBALS["strUnsubscribe"] . '"></p>'; } $res .= '<p>' . $GLOBALS["PoweredBy"] . '</p>'; $res .= $pagedata["footer"]; return $res; }
logEvent('email ' . $userdata['email'] . ' blacklisted by bounce rule ' . PageLink2('bouncerule&id=' . $rule['id'], $rule['id'])); addEmailToBlackList($userdata['email'], s('Email address auto blacklisted by bounce rule %d', $rule['id'])); $advanced_report .= 'email ' . $userdata['email'] . ' blacklisted by bounce rule ' . $rule['id'] . "\n"; $advanced_report .= 'User: '******'/?page=user&id=' . $userdata['id'] . "\n"; $advanced_report .= 'Rule: ' . $report_linkroot . '/?page=bouncerule&id=' . $rule['id'] . "\n"; addUserHistory($userdata['email'], $GLOBALS['I18N']->get("Auto Unsubscribed"), $GLOBALS['I18N']->get("email auto unsubscribed for") . " " . $GLOBALS['I18N']->get("bounce rule") . ' ' . $rule['id']); addSubscriberStatistics('auto blacklist', 1); break; case 'blacklistemailanddeletebounce': logEvent('email ' . $userdata['email'] . ' blacklisted by bounce rule ' . PageLink2('bouncerule&id=' . $rule['id'], $rule['id'])); addEmailToBlackList($userdata['email'], s('Email address auto blacklisted by bounce rule %d', $rule['id'])); $advanced_report .= 'email ' . $userdata['email'] . ' blacklisted by bounce rule ' . $rule['id'] . "\n"; $advanced_report .= 'User: '******'/?page=user&id=' . $userdata['id'] . "\n"; $advanced_report .= 'Rule: ' . $report_linkroot . '/?page=bouncerule&id=' . $rule['id'] . "\n"; addUserHistory($userdata['email'], $GLOBALS['I18N']->get("Auto Unsubscribed"), $GLOBALS['I18N']->get("User auto unsubscribed for") . " " . $GLOBALS['I18N']->get("bounce rule") . ' ' . $rule['id']); addSubscriberStatistics('auto blacklist', 1); deleteBounce($row['bounce']); break; case 'deletebounce': deleteBounce($row['bounce']); break; } $matched++; } else { $notmatched++; } } } outputProcessBounce($matched . ' ' . $GLOBALS['I18N']->get('bounces processed by advanced processing')); outputProcessBounce($notmatched . ' ' . $GLOBALS['I18N']->get('bounces were not matched by advanced processing rules')); }
if ($alive) { keepLock($process_id); } else { ProcessError($GLOBALS['I18N']->get("Process Killed by other process")); } if (sprintf('%d', $bounce["bounce"]) == $bounce["bounce"]) { $cnt++; if ($cnt >= $bounce_unsubscribe_treshold) { $removed = 1; output(sprintf('unsubscribing %d -> %d bounces', $user[0], $cnt)); $userurl = PageLink2("user&id={$user['0']}", $user[0]); logEvent($GLOBALS['I18N']->get("User") . " {$userurl} " . $GLOBALS['I18N']->get("has consecutive bounces") . " ({$cnt}) " . $GLOBALS['I18N']->get("over treshold, user marked unconfirmed")); $emailreq = Sql_Fetch_Row_Query("select email from {$tables["user"]} where id = {$user['0']}"); addUserHistory($emailreq[0], $GLOBALS['I18N']->get("Auto Unsubscribed"), $GLOBALS['I18N']->get("User auto unsubscribed for") . " {$cnt} " . $GLOBALS['I18N']->get("consecutive bounces")); Sql_Query(sprintf('update %s set confirmed = 0 where id = %d', $tables["user"], $user[0])); addSubscriberStatistics('auto unsubscribe', 1); $email_req = Sql_Fetch_Row_Query(sprintf('select email from %s where id = %d', $tables["user"], $user[0])); $unsubscribed_users .= $email_req[0] . " [{$user['0']}] ({$cnt})\n"; } } elseif ($bounce["bounce"] == "") { $cnt = 0; } } if ($usercnt % 10 == 0) { output($GLOBALS['I18N']->get("Identifying consecutive bounces")); output("{$usercnt} " . $GLOBALS['I18N']->get("of") . " {$total} " . $GLOBALS['I18N']->get("users processed"), 1); } $usercnt++; flush(); } if (!$GLOBALS["commandline"]) {