$nletter_activation = $cfg['mainurl'] . "/plug.php?e=newsletter&email=" . $nletter_email . "&activate=" . $row['nletter_activation'];
        } else {
            $sql = sed_sql_query("INSERT INTO sed_newsletter (nletter_email, nletter_date, nletter_activation) values ('{$nletter_email}', '" . $sys['now'] . "', '{$nletter_activation}')");
            $nletter_activation = $cfg['mainurl'] . "/plug.php?e=newsletter&email=" . $nletter_email . "&activate=" . $nletter_activation;
        }
        $nlsubject = $L['plu_amail_subject'];
        $nlbody = sprintf($L['plu_amail_body'], $nletter_activation);
        sed_mail($nletter_email, $nlsubject, $nlbody);
        $plugin_body = "<p style=\"text-align:center;\">" . $L['plu_joined'] . "</p>";
    }
} elseif ($a == $L['plu_cancel']) {
    $sql = sed_sql_query("SELECT nletter_activation FROM sed_newsletter WHERE nletter_email='{$nletter_email}' LIMIT 1");
    $error_string .= sed_sql_numrows($sql) != 1 ? $L['plu_email_cancelfailed'] . "<br />" : '';
    if (empty($error_string)) {
        $row = sed_sql_fetcharray($sql);
        $nletter_cancel = $cfg['mainurl'] . "/plug.php?e=newsletter&email=" . $nletter_email . "&cancel=" . $row['nletter_activation'];
        $nlsubject = $L['plu_cmail_subject'];
        $nlbody = sprintf($L['plu_cmail_body'], $nletter_cancel);
        sed_mail($nletter_email, $nlsubject, $nlbody);
        $plugin_body = "<p style=\"text-align:center;\">" . $L['plu_canceled'] . "</p>";
    }
}
if (empty($plugin_body)) {
    $plugin_body .= $L['plu_intro'];
    $plugin_body .= $error_string ? "<p><span style=\"color:red;\">" . $error_string . "</span></p>" : "";
    $plugin_body .= "<form name='newsletter' action='plug.php?e=newsletter' method='post'>";
    $plugin_body .= "<p>" . $L['plu_email'] . ":<input type=\"text\" name=\"nletter_email\" value=\"\" size=\"36\" maxlength=\"64\">";
    $plugin_body .= "<input type='submit' name='a' value='" . $L['plu_join'] . "'>";
    $plugin_body .= "<input type='submit' name='a' value='" . $L['plu_cancel'] . "'></p>";
    $plugin_body .= "</form>";
}
         $uwd_sqlgroups = sed_sql_query("SELECT gru_groupid FROM {$db_groups_users} WHERE gru_userid='{$uwd_userid}' " . $uwd_sqlargs . "");
         $uwd_sqlnum = sed_sql_numrows($uwd_sqlgroups);
         //do the query for main group
         if ($uwd_buildsqlargs2 != '') {
             $uwd_sqlargs2 = ' AND (' . $uwd_buildsqlargs2 . ')';
         }
         $uwd_sqlgroups2 = sed_sql_query("SELECT user_maingrp FROM {$db_users} WHERE user_id='{$uwd_userid}' " . $uwd_sqlargs2 . "");
         $uwd_sqlnum2 = sed_sql_numrows($uwd_sqlgroups2);
         $uwd_setreprievedate = $uwd_sqlnum + $uwd_sqlnum2 > 0 ? TRUE : FALSE;
     } else {
         //there is no group to exclude
         $uwd_setreprievedate = TRUE;
     }
     if ($uwd_setreprievedate == TRUE) {
         //send them a mail to give them a chance to come back
         sed_mail($uwd_email, $uwd_title, $uwd_message);
         //save the reprieve date in the banexpire field
         $sqltmp = sed_sql_query("UPDATE {$db_users} SET " . $uwd_reprieveslot . "='{$uwd_now}' WHERE user_id='{$uwd_userid}'");
         $uwd_counter++;
     }
 }
 if ($uwd_counter > 0) {
     sed_log("User watchdog plugin sent " . $uwd_counter . " inactivity warning(s)", 'adm');
 }
 //delete user which reached the reprieve date
 $sql = sed_sql_query("SELECT user_id, user_name FROM {$db_users} WHERE " . $uwd_reprieveslot . ">'0' AND " . $uwd_reprieveslot . "<'{$uwd_reprieve}'");
 while ($row = sed_sql_fetcharray($sql)) {
     //if there is the trashcan enabled, we put it there
     if ($cfg['trash_user']) {
         $sqltrash = sed_sql_query("SELECT * FROM {$db_users} WHERE user_id='" . $row['user_id'] . "'");
         if ($rowtrash = sed_sql_fetchassoc($sqltrash)) {
$nltitle = sed_import('nltitle', 'P', 'HTM');
$nlmessage = sed_import('nlmessage', 'P', 'HTM');
//Check the rights
$admin = sed_auth('plug', 'newsletter', 'A');
$read = sed_auth('plug', 'newsletter', 'R');
$write = sed_auth('plug', 'newsletter', 'W');
//
require "plugins/newsletter/lang/newsletter." . $usr['lang'] . ".lang.php";
if ($a == "send" && $write == TRUE) {
    $sql = sed_sql_query("SELECT * FROM sed_newsletter WHERE nletter_active='1'");
    while ($row = sed_sql_fetcharray($sql)) {
        $nletter_email = $row['nletter_email'];
        $nletter_activation = $row['nletter_activation'];
        $nletter_cancellink = $cfg['mainurl'] . "/plug.php?e=newsletter&email=" . $nletter_email . "&cancel=" . $row['nletter_activation'];
        $nlmessage2 = $nlmessage . "" . sprintf($L['plu_newsletter_body'], $nletter_cancellink);
        sed_mail($nletter_email, $nltitle, $nlmessage2);
        unset($nlmessage2);
    }
    $plugin_body .= "<p style=\"text-align:center;color:green;\">" . $L['plu_form_sent'] . "</p>";
} elseif ($write == TRUE) {
    if ($a == "addorremove") {
        $sql = sed_sql_query("SELECT nletter_activation, nletter_active FROM sed_newsletter WHERE nletter_email='" . $nletter_email . "'");
        $exist = sed_sql_numrows($sql);
        if ($exist > 0) {
            $row = sed_sql_fetcharray($sql);
        }
        if ($b == $L['plu_add']) {
            $nletter_activation = md5(microtime());
            $ar_error_string .= $row['nletter_active'] == 1 ? $L['plu_email_exists'] . "<br />" : '';
            $ar_error_string .= strlen($nletter_email) < 4 || !eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]{2,})+\$", $nletter_email) ? $L['plu_email_invalid'] . "<br />" : '';
            if (empty($ar_error_string)) {