diff --git a/bin/dbsv-update.php b/bin/dbsv-update.php index a3d45e13..5e44bd77 100644 --- a/bin/dbsv-update.php +++ b/bin/dbsv-update.php @@ -181,4 +181,10 @@ sql("ALTER TABLE `user` ADD COLUMN `mailing_problems` int(10) unsigned NOT NULL default '0' AFTER `last_email_problem`"); } + function dbv_109() // improved email-bounce processiong + { + if (!sql_field_exists('user','first_email_problem')) + sql("ALTER TABLE `user` ADD COLUMN `first_email_problem` date default NULL AFTER `email_problems`"); + } + ?> \ No newline at end of file diff --git a/htdocs/doc/sql/stored-proc/maintain.php b/htdocs/doc/sql/stored-proc/maintain.php index 5146b87a..0a787663 100644 --- a/htdocs/doc/sql/stored-proc/maintain.php +++ b/htdocs/doc/sql/stored-proc/maintain.php @@ -525,9 +525,8 @@ /* After reaching the 5-bounces limit, we try to send new cache notifications in larger intervals for some more time, and at least on per year. See also runwatch.php. */ - WHERE (`email_problems` < 5 - OR (`email_problems` < 10 AND NOW() > IFNULL(`last_email_problem`,'2013-03-01') + INTERVAL 30 DAY) - OR NOW() > IFNULL(`last_email_problem`,'2013-03-01') + INTERVAL 365 DAY) + WHERE (`email_problems` = 0 OR NOT `email` LIKE '%@aol.%') AND + (`email_problems` < 5 OR (`last_email_problem`-`first_email_problem` <= 90 AND NOW() > `last_email_problem` + INTERVAL 30 DAY)) AND NOT ISNULL(`user`.`latitude`) AND NOT ISNULL(`user`.`longitude`) AND `user`.`notify_radius`>0 @@ -1254,6 +1253,11 @@ SET NEW.`last_modified`=NOW(); END IF; END IF; + IF NEW.`email_problems`>0 AND NEW.`first_email_problem` IS NULL THEN + SET NEW.`first_email_problem` = NEW.`last_email_problem`; + ELSEIF NEW.`email_problems`=0 THEN + SET NEW.`first_email_problem` = NULL; + END IF; END;"); sql_dropTrigger('userBeforeDelete'); diff --git a/htdocs/doc/sql/tables/user.sql b/htdocs/doc/sql/tables/user.sql index 2a5864de..fa80e7a2 100644 --- a/htdocs/doc/sql/tables/user.sql +++ b/htdocs/doc/sql/tables/user.sql @@ -11,6 +11,7 @@ CREATE TABLE `user` ( `password` varchar(32) default NULL, `email` varchar(60) default NULL, `email_problems` int(10) NOT NULL default '0', + `first_email_problem` date default NULL, `last_email_problem` datetime default NULL, `mailing_problems` int(10) unsigned NOT NULL default '0', `latitude` double NOT NULL, diff --git a/htdocs/util/watchlist/runwatch.php b/htdocs/util/watchlist/runwatch.php index 6e8f4d16..2cf99241 100755 --- a/htdocs/util/watchlist/runwatch.php +++ b/htdocs/util/watchlist/runwatch.php @@ -81,7 +81,10 @@ // Watch notifications are discarded if the user had some undeliverable emails. // See also stored procedure sp_notify_new_cache(). - if (sqlValue("SELECT `email_problems` FROM `user` WHERE `user_id`='" . sql_escape($rcw['user_id']) . "'", 0) < 5) + // See http://forum.opencaching-network.org/index.php?topic=3123.0 on AOL. + if (sqlValue("SELECT (`email_problems`=0 OR NOT `email` LIKE '%@aol.%') + AND (`email_problems`<5 OR `last_email_problem`-`first_email_problem` < 10) + FROM `user` WHERE `user_id`='" . sql_escape($rcw['user_id']) . "'", 0)) process_log_watch($rcw['user_id'], $rcw['log_id']); sql("DELETE FROM `watches_logqueue` WHERE `log_id`='&1' AND `user_id`='&2'", $rcw['log_id'], $rcw['user_id']); diff --git a/htdocs/util2/cron/modules/maillog.class.php b/htdocs/util2/cron/modules/maillog.class.php index f4e600b8..2b5b5bd8 100644 --- a/htdocs/util2/cron/modules/maillog.class.php +++ b/htdocs/util2/cron/modules/maillog.class.php @@ -42,7 +42,7 @@ class maillog echo $this->name.": could not connect to syslog database\n"; return; } - if (@mysql_query("USE ".$opt['system']['maillog']['syslog_db_name']) === FALSE) + if (@mysql_query("USE ".$opt['system']['maillog']['syslog_db_name'], $dbc) === FALSE) { echo $this->name.": could not open syslog database: ".mysql_error()."\n"; return; @@ -59,7 +59,7 @@ class maillog WHERE (`id`>'" . mysql_real_escape_string($last_id) . "' OR `created`>'" . mysql_real_escape_string($last_date) . "') AND `host_name`='" . mysql_real_escape_string($opt['system']['maillog']['syslog_oc_host']) . "' AND `program`='" . mysql_real_escape_string($opt['system']['maillog']['syslog_mta']) . "' - ORDER BY `id`"); + ORDER BY `id`", $dbc); if ($rs === FALSE) { echo $this->name.": syslog query error (".mysql_errno()."): ".mysql_error()."\n";