--- amavisnewsql.class.php.original 2005-05-17 09:00:28.000000000 -0600 +++ amavisnewsql.class.php 2007-06-29 22:41:46.000000000 -0600 @@ -1,4 +1,4 @@ -error = null; - if($username == null || $tag2_level == null || $kill_level == null) { + if($username == null || $tag2_level == null || $kill_level == null || $spam_quarantine_cutoff_level == null) { $this->error = "Improper arguments supplied for ".__FUNCTION__." function"; return FALSE; } - - if(!$this->_ValidatePolicyRanges($tag2_level, $kill_level)) return FALSE; + + if(!$this->_ValidatePolicyRanges($tag2_level, $kill_level, $spam_quarantine_cutoff_level)) return FALSE; + + if($spam_quarantine_cutoff_level < $kill_level){ + $spam_quarantine_cutoff_level = $kill_level; + } $q = "select id,policy_id from $this->users_table where username = '$username'"; @@ -716,7 +726,8 @@ if($row["policy_id"] > 10) { // We are changing an existing custom policy $q = "update $this->policy_table set spam_tag2_level = '$tag2_level', - spam_kill_level = '$kill_level' + spam_kill_level = '$kill_level', + spam_quarantine_cutoff_level = '$spam_quarantine_cutoff_level' where id = $row[policy_id]"; if (!$res = $this->sqlWrite($q, __FUNCTION__, __LINE__)) { @@ -729,8 +740,8 @@ $nextid = $this->db->nextID("policy_id"); $q = "insert into $this->policy_table - (id,policy_name,spam_tag2_level,spam_kill_level) - values ($nextid,'Custom','$tag2_level','$kill_level')"; + (id,policy_name,spam_tag2_level,spam_kill_level,spam_quarantine_cutoff_level) + values ($nextid,'Custom','$tag2_level','$kill_level','$spam_quarantine_cutoff_level')"; if (!$res1 = $this->sqlWrite($q, __FUNCTION__, __LINE__)) { $this->sqlWrite("rollback"); @@ -810,9 +821,10 @@ * * @param float tag2 numerical score * @param float kill numerical score + * @param float cutoff numerical score * @returns bool True on success False on failure */ - function _ValidatePolicyRanges($tag2, $kill) { + function _ValidatePolicyRanges($tag2, $kill, $cutoff) { $this->error = null; if($kill == "" || $tag2 == "") { @@ -821,9 +833,25 @@ } if($kill < $tag2) { - $this->error = "Tag Level is Higher Than Quarantine Level"; + $this->error = "Tag Level $tag2 is Higher Than Kill Level $kill, try using decimal places."; return FALSE; } + + if($kill < 6.5) { + $this->error = "For your safety, Kill Level cannot be less than 6.5"; + return FALSE; + } + + if($tag2 < 4) { + $this->error = "For your safety, Tag2 Level cannot be less than 4"; + return FALSE; + } + + if($cutoff < 8) { + $this->error = "For your safety, Cutoff Level Level cannot be less than 8"; + return FALSE; + } + return TRUE; } @@ -888,12 +916,12 @@ // currently if they change from a custom to a predefined it will remove their custom policy entry // and loose the quarantine settings... for now I'm ok with this. - $q = "select spam_tag2_level,spam_kill_level,policy_id from users,policy where username = '$username' and policy_id = policy.id"; + $q = "select spam_tag2_level,spam_kill_level,spam_quarantine_cutoff_level,policy_id from users,policy where username = '$username' and policy_id = policy.id"; if (!$res = $this->sqlRead($q, __FUNCTION__, __LINE__)) return FALSE; $row = $res->fetchRow(DB_FETCHMODE_ASSOC); - if (!$this->setcustompolicy($username, $row["spam_tag2_level"], $row["spam_kill_level"])) return FALSE; + if (!$this->setcustompolicy($username, $row["spam_tag2_level"], $row["spam_kill_level"], $row["spam_quarantine_cutoff_level"])) return FALSE; // Now that we have created them a custom policy based on the settings from their previous one.. get // the new policy ID number. @@ -1056,6 +1084,7 @@ $q = "select $this->policy_table.policy_name, $this->policy_table.spam_tag2_level, $this->policy_table.spam_kill_level, + $this->policy_table.spam_quarantine_cutoff_level, $this->users_table.id, $this->users_table.email from $this->policy_table, $this->users_table @@ -1075,6 +1104,7 @@ $PolicyList[$i]["id"] = $row["id"]; $PolicyList[$i]["tag2_level"] = $row["spam_tag2_level"]; $PolicyList[$i]["kill_level"] = $row["spam_kill_level"]; + $PolicyList[$i]["spam_quarantine_cutoff_level"] = $row["spam_quarantine_cutoff_level"]; } return $PolicyList; } --- amavisnewsql.php.original 2007-06-29 20:45:46.000000000 -0600 +++ amavisnewsql.php 2007-06-29 20:47:11.000000000 -0600 @@ -139,7 +139,8 @@ case "set_custom_policy": sqgetGlobalVar('tag2_level', $tag2_level, SQ_REQUEST); sqgetGlobalVar('kill_level', $kill_level, SQ_REQUEST); - if(!$dbfp->SetCustomPolicy($username, $tag2_level, $kill_level, __FILE__, __LINE__)) { + sqgetGlobalVar('spam_quarantine_cutoff_level', $spam_quarantine_cutoff_level, SQ_REQUEST); + if(!$dbfp->SetCustomPolicy($username, $tag2_level, $kill_level, $spam_quarantine_cutoff_level, __FILE__, __LINE__)) { amavisnewsql_ErrorOut($dbfp->error, TRUE); } amavisnewsql_DisplayOptions(NULL, NULL, __FILE__, __LINE__); --- functions.php.original 2005-04-03 16:15:07.000000000 -0600 +++ functions.php 2007-06-29 22:26:12.000000000 -0600 @@ -3,7 +3,7 @@ * This is where I put stuff that is specific to this plugin.. but * does not belong in the class. Most of the output screens are done * here. This is also where you can customize how errors are handled. - * + * * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @author Jared Watkins 2003 * @package amavisnewsql @@ -11,6 +11,10 @@ */ /** + * Customized by Gary V, mr88talent at yahoo dot com + */ + +/** * Handles all error output */ function amavisnewsql_ErrorOut($err, $fatal=false) { @@ -265,7 +269,7 @@
" . _("Whitelist / Blacklist") . "

" . - _("Here you may list the addresses you wish to protect and those you wish to block. Please keep in mind that spammers often have throw-away or fake addresses so blacklisting these is pointless. The listed addresses appear in the same order as they will be applied by the mail server. Please read the section on priority to understand why this is important.") . " + _("Here you may list the addresses you wish to protect and those you wish to block. Please keep in mind that spammers often have throw-away or fake addresses so blacklisting these is pointless. Also note that it is the 'Envelope Sender' that is acted on. This is not always the same as the 'From' address. Contact the postmaster if your setting does not appear to make any difference. The listed addresses appear in the same order as they will be applied by the mail server. Please read the section on priority to understand why this is important.") . "
" . _("Priority") . "

" . @@ -375,10 +379,10 @@ - \n - \n + \n + \n \n - \n + \n "; for($i=0; $i < count($policyList); $i++) { @@ -386,7 +390,8 @@ echo "\n \n - \n"; + \n + \n"; } echo " @@ -401,8 +406,8 @@ - + - + -
" . _("Your Current Policy") . "" . _("Tag Level") . "$tag2_label
".$myPolicy[0]["policy_name"]."".$myPolicy[0]["tag2_level"]."".$myPolicy[0]["kill_level"]."
" . _("Your Current Policy") . "" . _("Tag2 Level") . "$tag2_label" . _("Cutoff Level") . "
".$myPolicy[0]["policy_name"]."".$myPolicy[0]["tag2_level"]."".$myPolicy[0]["kill_level"]."".$myPolicy[0]["spam_quarantine_cutoff_level"]."

" . _("Predefined Policies") . "
(" . _("Click To Select") . ")
" . _("Tag Level") . "$tag2_label
" . _("Predefined Policies") . "
(" . _("Click To Select") . ")
" . _("Tag2 Level") . "$tag2_label" . _("Cutoff Level") . "
$setlink".$policyList[$i]["tag2_level"]."".$policyList[$i]["kill_level"]."
".$policyList[$i]["kill_level"]."".$policyList[$i]["spam_quarantine_cutoff_level"]."
" . _("Custom Policy") . " -
+
@@ -418,11 +423,14 @@
" . _("Policies") . "

" . _("You may select from one of several predefined scoring policies or you may define your own. Each email is assigned a numerical score based on the characteristics it shares with those common to spam.") . "
" . _("Tag Level") . "

" . - _("The tag level is the numerical score required to identify a message as being spam. This will cause *SPAM* to be added to the subject line and the X-Spam-Flag header to be set to YES.") . " +
" . _("Tag2 Level") . "

" . + _("If a message scores at or above Tag2 Level, that message will be marked as spam. This will cause Spam> to be prefixed to the Subject line, the X-Spam-Flag header set to YES and the message directed to your Spam folder. The minimum setting is 4. Messages in your Spam folder need to be reviewed and either moved to another folder, or deleted. They will automatically be deleted after 24 days.") . " +
$tag2_label

" . + _("If a message scores at or above ") . _("$tag2_label") . _(", that message will be placed in quarantine. This level should be higher or equal to Tag2 Level and high enough to avoid quarantining legitimate mail. The minimum setting is 6.5. Messages in the quarantine are deleted after 24 days so please review them regularly. Set ") . _("$tag2_label") . _(" high if you wish to avoid spam quarantine.") . "
$tag2_label

" . - _("The ") . _("$tag2_label") . _(" is the numerical score required to prevent delivery of a message at the server. This level should be higher or equal to Tag Level and high enough to avoid catching legitimate email. As your custom whitelist grows you should adjust these two levels to tag and block more spam.") . " +
" . _("Cutoff Level") . "

" . + _("The Cutoff Level is the score at which a message is permanently deleted. This level must be higher or equal to Kill Level and high enough to avoid deleting legitimate mail. The minimum setting is 8, but a higher setting is strongly advised because you will occasionally delete legitimate mail at that level. Somewhere around 14 would be much safer. Set cutoff level high if you wish to avoid spam deletion.") . "