diff --git a/LICENSE b/LICENSE index 580ceadf..de3f45a3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,19 +1,16 @@ -Copyright (C) 2011, SJ +piler, an enterprise level email archiving application -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. +Copyright (C) 2012, Janos SUTO -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 3 of the License. -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. -2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. +You should have received a copy of the GNU General Public License +along with this program. If not, see . -3. This notice may not be removed or altered from any source distribution. diff --git a/etc/example.conf b/etc/example.conf index a4182dfa..8cce7561 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -11,6 +11,12 @@ verbosity=1 ; it it was started by root username=piler +; by default (unless a specific retention rule applies), +; preserve an email for this many days. The purge utility +; won't harm the message until its retention days are gone. +; The default is 7 years + 2 days (=7*365+2=2557 days) +default_retention_days=2557 + ; this is a 16 character long vector iv=**************** diff --git a/src/cfg.c b/src/cfg.c index 77283a54..41ae0c00 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -63,6 +63,7 @@ struct _parse_rule config_parse_rules[] = { "clamd_addr", "string", (void*) string_parser, offsetof(struct __config, clamd_addr), "", MAXVAL-1}, { "clamd_port", "integer", (void*) int_parser, offsetof(struct __config, clamd_port), "0", sizeof(int)}, { "clamd_socket", "string", (void*) string_parser, offsetof(struct __config, clamd_socket), CLAMD_SOCKET, MAXVAL-1}, + { "default_retention_days", "integer", (void*) int_parser, offsetof(struct __config, default_retention_days), "2557", sizeof(int)}, { "hostid", "string", (void*) string_parser, offsetof(struct __config, hostid), HOSTID, MAXVAL-1}, { "iv", "string", (void*) string_parser, offsetof(struct __config, iv), "", MAXVAL-1}, { "listen_addr", "string", (void*) string_parser, offsetof(struct __config, listen_addr), "127.0.0.1", MAXVAL-1}, diff --git a/src/cfg.h b/src/cfg.h index 82334a33..6c688ce9 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -47,6 +47,8 @@ struct __config { char spam_header_line[MAXVAL]; + int default_retention_days; + // mysql stuff char mysqlhost[MAXVAL]; diff --git a/src/config.h b/src/config.h index f4a237ba..3eae5260 100644 --- a/src/config.h +++ b/src/config.h @@ -78,6 +78,7 @@ #define SQL_ATTACHMENT_TABLE "attachment" #define SQL_RECIPIENT_TABLE "rcpt" #define SQL_ARCHIVING_RULE_TABLE "archiving_rule" +#define SQL_RETENTION_RULE_TABLE "retention_rule" #define SQL_COUNTER_TABLE "counter" #define SQL_MESSAGES_VIEW "messages" diff --git a/src/defs.h b/src/defs.h index 99217b8c..aaa4647a 100644 --- a/src/defs.h +++ b/src/defs.h @@ -93,13 +93,17 @@ struct rule { regex_t subject; regex_t attachment_type; #endif + int spam; int size; char _size[4]; int attachment_size; char _attachment_size[4]; + int days; + char *rulestr; char compiled; + struct rule *r; }; @@ -165,7 +169,7 @@ struct session_data { float __acquire, __parsed, __av, __store, __compress, __encrypt; char bodydigest[2*DIGEST_LENGTH+1]; char digest[2*DIGEST_LENGTH+1]; - time_t now, sent; + time_t now, sent, retained; #ifdef NEED_MYSQL MYSQL mysql; #endif @@ -217,7 +221,8 @@ struct memcached_server { struct __data { #ifdef HAVE_TRE - struct rule *rules; + struct rule *archiving_rules; + struct rule *retention_rules; #endif #ifdef HAVE_MEMCACHED diff --git a/src/message.c b/src/message.c index 48eaf90d..cc5ba724 100644 --- a/src/message.c +++ b/src/message.c @@ -278,7 +278,7 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __c subj = state->b_subject; if(*subj == ' ') subj++; - snprintf(s, sizeof(s)-1, "%llu+%s%s%s%ld%ld%d%d%d%d%s%s%s", id, subj, state->b_from, state->message_id, sdata->now, sdata->sent, sdata->tot_len, sdata->hdr_len, sdata->direction, state->n_attachments, sdata->ttmpfile, sdata->digest, sdata->bodydigest); + snprintf(s, sizeof(s)-1, "%llu+%s%s%s%ld%ld%ld%d%d%d%d%s%s%s", id, subj, state->b_from, state->message_id, sdata->now, sdata->sent, sdata->retained, sdata->tot_len, sdata->hdr_len, sdata->direction, state->n_attachments, sdata->ttmpfile, sdata->digest, sdata->bodydigest); digest_string(s, &vcode[0]); @@ -286,7 +286,7 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __c if(strlen(state->reference) > 10) digest_string(state->reference, &ref[0]); - snprintf(s, MAXBUFSIZE-1, "INSERT INTO %s (`from`,`fromdomain`,`subject`,`spam`,`arrived`,`sent`,`size`,`hlen`,`direction`,`attachments`,`piler_id`,`message_id`,`reference`,`digest`,`bodydigest`,`vcode`) VALUES(?,?,?,%d,%ld,%ld,%d,%d,%d,%d,'%s',?,'%s','%s','%s','%s')", SQL_METADATA_TABLE, sdata->spam_message, sdata->now, sdata->sent, sdata->tot_len, sdata->hdr_len, sdata->direction, state->n_attachments, sdata->ttmpfile, ref, sdata->digest, sdata->bodydigest, vcode); + snprintf(s, MAXBUFSIZE-1, "INSERT INTO %s (`from`,`fromdomain`,`subject`,`spam`,`arrived`,`sent`,`retained`,`size`,`hlen`,`direction`,`attachments`,`piler_id`,`message_id`,`reference`,`digest`,`bodydigest`,`vcode`) VALUES(?,?,?,%d,%ld,%ld,%ld,%d,%d,%d,%d,'%s',?,'%s','%s','%s','%s')", SQL_METADATA_TABLE, sdata->spam_message, sdata->now, sdata->sent, sdata->retained, sdata->tot_len, sdata->hdr_len, sdata->direction, state->n_attachments, sdata->ttmpfile, ref, sdata->digest, sdata->bodydigest, vcode); if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: meta sql: *%s*", sdata->ttmpfile, s); @@ -412,6 +412,8 @@ int process_message(struct session_data *sdata, struct _state *state, struct __d } + sdata->retained += query_retain_period(data->retention_rules, state, sdata->tot_len, sdata->spam_message, cfg); + rc = store_meta_data(sdata, state, cfg); if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: stored metadata, rc=%d", sdata->ttmpfile, rc); if(rc == ERR_EXISTS) return ERR_EXISTS; diff --git a/src/misc.c b/src/misc.c index 537694fc..5dc0d9cd 100644 --- a/src/misc.c +++ b/src/misc.c @@ -405,7 +405,7 @@ void init_session_data(struct session_data *sdata){ for(i=0; ircptto[i], 0, SMALLBUFSIZE); time(&(sdata->now)); - sdata->sent = sdata->now; + sdata->sent = sdata->retained = sdata->now; } diff --git a/src/piler.c b/src/piler.c index f4f9ef97..120d66f9 100644 --- a/src/piler.c +++ b/src/piler.c @@ -238,7 +238,8 @@ void clean_exit(){ kill_children(SIGTERM); - free_rule(data.rules); + free_rule(data.archiving_rules); + free_rule(data.retention_rules); syslog(LOG_PRIORITY, "%s has been terminated", PROGNAME); @@ -282,8 +283,11 @@ void initialise_configuration(){ setlocale(LC_CTYPE, cfg.locale); - free_rule(data.rules); - data.rules = NULL; + free_rule(data.archiving_rules); + free_rule(data.retention_rules); + + data.archiving_rules = NULL; + data.retention_rules = NULL; mysql_init(&(sdata.mysql)); mysql_options(&(sdata.mysql), MYSQL_OPT_CONNECT_TIMEOUT, (const char*)&cfg.mysql_connect_timeout); @@ -292,7 +296,8 @@ void initialise_configuration(){ return; } - load_archiving_rules(&sdata, &(data.rules)); + load_rules(&sdata, &(data.archiving_rules), SQL_ARCHIVING_RULE_TABLE); + load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE); mysql_close(&(sdata.mysql)); @@ -334,7 +339,8 @@ int main(int argc, char **argv){ (void) openlog(PROGNAME, LOG_PID, LOG_MAIL); - data.rules = NULL; + data.archiving_rules = NULL; + data.retention_rules = NULL; initialise_configuration(); diff --git a/src/pilerexport.c b/src/pilerexport.c index 47a7b217..526595f5 100644 --- a/src/pilerexport.c +++ b/src/pilerexport.c @@ -228,14 +228,15 @@ int main(int argc, char **argv){ {"to", required_argument, 0, 'r' }, {"start-date", required_argument, 0, 'a' }, {"stop-date", required_argument, 0, 'b' }, + {"id", required_argument, 0, 'i' }, {0,0,0,0} }; int option_index = 0; - c = getopt_long(argc, argv, "c:s:S:f:r:a:b:Adhv?", long_options, &option_index); + c = getopt_long(argc, argv, "c:s:S:f:r:a:b:i:Adhv?", long_options, &option_index); #else - c = getopt(argc, argv, "c:s:S:f:r:a:b:Adhv?"); + c = getopt(argc, argv, "c:s:S:f:r:a:b:i:Adhv?"); #endif if(c == -1) break; diff --git a/src/pilerimport.c b/src/pilerimport.c index e7fcf63d..0af1aff6 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -50,7 +50,11 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da if(sdata->sent > sdata->now) sdata->sent = sdata->now; if(sdata->sent == -1) sdata->sent = 0; - rule = check_againt_ruleset(data->rules, &state, st.st_size); + /* fat chances that you won't import emails before 1990.01.01 */ + + if(sdata->sent > 631148400) sdata->retained = sdata->sent; + + rule = check_againt_ruleset(data->archiving_rules, &state, st.st_size, sdata->spam_message); if(rule){ printf("discarding %s by archiving policy: %s\n", filename, rule); @@ -230,9 +234,11 @@ int main(int argc, char **argv){ setlocale(LC_CTYPE, cfg.locale); - data.rules = NULL; + data.archiving_rules = NULL; + data.retention_rules = NULL; - load_archiving_rules(&sdata, &(data.rules)); + load_rules(&sdata, &(data.archiving_rules), SQL_ARCHIVING_RULE_TABLE); + load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE); @@ -242,7 +248,8 @@ int main(int argc, char **argv){ - free_rule(data.rules); + free_rule(data.archiving_rules); + free_rule(data.retention_rules); mysql_close(&(sdata.mysql)); diff --git a/src/rules.c b/src/rules.c index 6d0ef69e..a0a1e275 100644 --- a/src/rules.c +++ b/src/rules.c @@ -10,18 +10,18 @@ #include "rules.h" -void load_archiving_rules(struct session_data *sdata, struct rule **rules){ +void load_rules(struct session_data *sdata, struct rule **rules, char *table){ char s[SMALLBUFSIZE]; MYSQL_RES *res; MYSQL_ROW row; - snprintf(s, sizeof(s)-1, "SELECT `from`, `to`, `subject`, `_size`, `size`, `attachment_type`, `_attachment_size`, `attachment_size` FROM `%s`", SQL_ARCHIVING_RULE_TABLE); + snprintf(s, sizeof(s)-1, "SELECT `from`, `to`, `subject`, `_size`, `size`, `attachment_type`, `_attachment_size`, `attachment_size`, `spam`, `days` FROM `%s`", table); if(mysql_real_query(&(sdata->mysql), s, strlen(s)) == 0){ res = mysql_store_result(&(sdata->mysql)); if(res != NULL){ while((row = mysql_fetch_row(res))){ - append_rule(rules, (char*)row[0], (char*)row[1], (char*)row[2], (char*)row[3], atoi(row[4]), (char*)row[5], (char*)row[6], atoi(row[7])); + append_rule(rules, (char*)row[0], (char*)row[1], (char*)row[2], (char*)row[3], atoi(row[4]), (char*)row[5], (char*)row[6], atoi(row[7]), atoi(row[8]), atoi(row[9])); } mysql_free_result(res); @@ -32,7 +32,7 @@ void load_archiving_rules(struct session_data *sdata, struct rule **rules){ } -int append_rule(struct rule **rule, char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size){ +int append_rule(struct rule **rule, char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size, int spam, int days){ struct rule *q, *t, *u=NULL; q = *rule; @@ -42,7 +42,7 @@ int append_rule(struct rule **rule, char *from, char *to, char *subject, char *_ q = q->r; } - t = create_rule_item(from, to, subject, _size, size, attachment_type, _attachment_size, attachment_size); + t = create_rule_item(from, to, subject, _size, size, attachment_type, _attachment_size, attachment_size, spam, days); if(t){ if(*rule == NULL) *rule = t; @@ -56,7 +56,7 @@ int append_rule(struct rule **rule, char *from, char *to, char *subject, char *_ } -struct rule *create_rule_item(char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size){ +struct rule *create_rule_item(char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size, int spam, int days){ struct rule *h=NULL; char empty = '\0'; int len; @@ -76,6 +76,9 @@ struct rule *create_rule_item(char *from, char *to, char *subject, char *_size, if(!subject) subject = ∅ if(regcomp(&(h->subject), subject, REG_ICASE | REG_EXTENDED)) h->compiled = 0; + h->spam = spam; + h->days = days; + h->size = size; if(!_size) _size = ∅ @@ -91,12 +94,12 @@ struct rule *create_rule_item(char *from, char *to, char *subject, char *_size, if(!_attachment_size) _attachment_size = ∅ snprintf(h->_attachment_size, 3, "%s", _attachment_size); - len = strlen(from)+6 + strlen(to)+4 + strlen(subject)+9 + strlen(_size)+6 + strlen(attachment_type)+10 + strlen(_attachment_size)+10 + 15 + 15; + len = strlen(from)+6 + strlen(to)+4 + strlen(subject)+9 + strlen(_size)+6 + strlen(attachment_type)+10 + strlen(_attachment_size)+10 + 8 + 15 + 15; h->rulestr = malloc(len); - if(h->rulestr) snprintf(h->rulestr, len-1, "from=%s,to=%s,subject=%s,size%s%d,att.type=%s,att.size%s%d", from, to, subject, _size, size, attachment_type, _attachment_size, attachment_size); + if(h->rulestr) snprintf(h->rulestr, len-1, "from=%s,to=%s,subject=%s,size%s%d,att.type=%s,att.size%s%d,spam=%d", from, to, subject, _size, size, attachment_type, _attachment_size, attachment_size, spam); else h->compiled = 0; h->r = NULL; @@ -105,7 +108,7 @@ struct rule *create_rule_item(char *from, char *to, char *subject, char *_size, } -char *check_againt_ruleset(struct rule *rule, struct _state *state, int size){ +char *check_againt_ruleset(struct rule *rule, struct _state *state, int size, int spam){ size_t nmatch=0; struct rule *p; @@ -119,7 +122,8 @@ char *check_againt_ruleset(struct rule *rule, struct _state *state, int size){ regexec(&(p->to), state->b_to, nmatch, NULL, 0) == 0 && regexec(&(p->subject), state->b_subject, nmatch, NULL, 0) == 0 && check_size_rule(size, p->size, p->_size) == 1 && - check_attachment_rule(state, p) == 1 + check_attachment_rule(state, p) == 1 && + check_spam_rule(spam, p->spam) == 1 ){ return p->rulestr; } @@ -131,6 +135,33 @@ char *check_againt_ruleset(struct rule *rule, struct _state *state, int size){ } +unsigned long query_retain_period(struct rule *rule, struct _state *state, int size, int spam, struct __config *cfg){ + size_t nmatch=0; + struct rule *p; + + p = rule; + + while(p != NULL){ + + if( + p->compiled == 1 && + regexec(&(p->from), state->b_from, nmatch, NULL, 0) == 0 && + regexec(&(p->to), state->b_to, nmatch, NULL, 0) == 0 && + regexec(&(p->subject), state->b_subject, nmatch, NULL, 0) == 0 && + check_size_rule(size, p->size, p->_size) == 1 && + check_attachment_rule(state, p) == 1 && + check_spam_rule(spam, p->spam) == 1 + ){ + return p->days * 86400; + } + + p = p->r; + } + + return cfg->default_retention_days * 86400; +} + + int check_size_rule(int message_size, int size, char *_size){ if(size <= 0) return 1; @@ -143,6 +174,13 @@ int check_size_rule(int message_size, int size, char *_size){ } +int check_spam_rule(int is_spam, int spam){ + if(spam == -1) return 1; + if(is_spam == spam) return 1; + return 0; +} + + int check_attachment_rule(struct _state *state, struct rule *rule){ int i; size_t nmatch=0; diff --git a/src/rules.h b/src/rules.h index 0e471b99..69528ead 100644 --- a/src/rules.h +++ b/src/rules.h @@ -7,11 +7,13 @@ #include "defs.h" -void load_archiving_rules(struct session_data *sdata, struct rule **rules); -int append_rule(struct rule **rule, char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size); -struct rule *create_rule_item(char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size); -char *check_againt_ruleset(struct rule *rule, struct _state *state, int size); +void load_rules(struct session_data *sdata, struct rule **rules, char *table); +int append_rule(struct rule **rule, char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size, int spam, int days); +struct rule *create_rule_item(char *from, char *to, char *subject, char *_size, int size, char *attachment_type, char *_attachment_size, int attachment_size, int spam, int days); +char *check_againt_ruleset(struct rule *rule, struct _state *state, int size, int spam); +unsigned long query_retain_period(struct rule *rule, struct _state *state, int size, int spam, struct __config *cfg); int check_size_rule(int message_size, int size, char *_size); +int check_spam_rule(int is_spam, int spam); int check_attachment_rule(struct _state *state, struct rule *rule); void free_rule(struct rule *rule); diff --git a/src/session.c b/src/session.c index f1971461..10502606 100644 --- a/src/session.c +++ b/src/session.c @@ -193,7 +193,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){ /* check message against archiving rules */ - arule = check_againt_ruleset(data->rules, &sstate, sdata.tot_len); + arule = check_againt_ruleset(data->archiving_rules, &sstate, sdata.tot_len, sdata.spam_message); if(arule){ syslog(LOG_PRIORITY, "%s: discarding message by archiving policy: *%s*", sdata.ttmpfile, arule); diff --git a/src/test.c b/src/test.c index c25f655a..494c898e 100644 --- a/src/test.c +++ b/src/test.c @@ -51,9 +51,11 @@ int main(int argc, char **argv){ printf("locale: %s\n", setlocale(LC_MESSAGES, cfg.locale)); setlocale(LC_CTYPE, cfg.locale); - data.rules = NULL; + data.archiving_rules = NULL; + data.retention_rules = NULL; - load_archiving_rules(&sdata, &(data.rules)); + load_rules(&sdata, &(data.archiving_rules), SQL_ARCHIVING_RULE_TABLE); + load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE); rc = 0; @@ -82,13 +84,18 @@ int main(int argc, char **argv){ printf("hdr len: %d\n", sdata.hdr_len); - rule = check_againt_ruleset(data.rules, &state, st.st_size); + rule = check_againt_ruleset(data.archiving_rules, &state, st.st_size, sdata.spam_message); printf("body digest: %s\n", sdata.bodydigest); printf("rules check: %s\n", rule); - free_rule(data.rules); + sdata.retained = sdata.now + query_retain_period(data.retention_rules, &state, st.st_size, sdata.spam_message, &cfg); + + printf("retention period: %ld\n", sdata.retained); + + free_rule(data.archiving_rules); + free_rule(data.retention_rules); for(i=1; i<=state.n_attachments; i++){ printf("i:%d, name=*%s*, type: *%s*, size: %d, int.name: %s, digest: %s\n", i, state.attachments[i].filename, state.attachments[i].type, state.attachments[i].size, state.attachments[i].internalname, state.attachments[i].digest); diff --git a/util/db-mysql.sql b/util/db-mysql.sql index cf0237f9..80b53e10 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -38,6 +38,7 @@ create table if not exists `metadata` ( `spam` tinyint(1) default 0, `arrived` int not null, `sent` int not null, + `retained` int not null, `deleted` tinyint(1) default 0, `size` int default 0, `hlen` int default 0, @@ -58,6 +59,7 @@ create index metadata_idx3 on metadata(`reference`); create index metadata_idx4 on metadata(`bodydigest`); create index metadata_idx5 on metadata(`deleted`); create index metadata_idx6 on metadata(`arrived`); +create index metadata_idx7 on metadata(`retained`); drop table if exists `rcpt`; @@ -113,8 +115,28 @@ create table if not exists `archiving_rule` ( `attachment_type` char(128) character set 'latin1' default null, `_attachment_size` char(2) default null, `attachment_size` int default 0, + `spam` tinyint(1) default -1, + `days` int default 0, primary key (`id`), - unique(`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`) + unique(`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`) +) ENGINE=InnoDB; + + +drop table if exists `retention_rule`; +create table if not exists `retention_rule` ( + `id` bigint unsigned not null auto_increment, + `from` char(128) character set 'latin1' default null, + `to` char(255) character set 'latin1' default null, + `subject` char(255) character set 'latin1' default null, + `_size` char(2) default null, + `size` int default 0, + `attachment_type` char(128) character set 'latin1' default null, + `_attachment_size` char(2) default null, + `attachment_size` int default 0, + `spam` tinyint(1) default -1, + `days` int default 0, + primary key (`id`), + unique(`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`) ) ENGINE=InnoDB; diff --git a/webui/config.php b/webui/config.php index 8e72341c..8d837891 100644 --- a/webui/config.php +++ b/webui/config.php @@ -91,6 +91,7 @@ define('TABLE_DOMAIN', 'domain'); define('TABLE_COUNTER', 'counter'); define('TABLE_AUDIT', 'audit'); define('TABLE_ARCHIVING_RULE', 'archiving_rule'); +define('TABLE_RETENTION_RULE', 'retention_rule'); define('VIEW_MESSAGES', 'messages'); define('SPHINX_DRIVER', 'sphinx'); diff --git a/webui/controller/policy/archiving.php b/webui/controller/policy/archiving.php index c6853329..cd7a1d64 100644 --- a/webui/controller/policy/archiving.php +++ b/webui/controller/policy/archiving.php @@ -21,16 +21,16 @@ class ControllerPolicyArchiving extends Controller { $this->data['rules'] = array(); + if(Registry::get('admin_user') == 0) { + die("go away"); + } if($_SERVER['REQUEST_METHOD'] == 'POST') { $rc = $this->model_policy_archiving->add_new_rule($this->request->post); - } $this->data['rules'] = $this->model_policy_archiving->get_rules(); -//print_r($this->data['rules']); - $this->render(); } diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index 7ca71f88..52b9265d 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -170,6 +170,7 @@ $_['text_non_existent_queue_directory'] = "The queue directory you have specifie $_['text_non_existing_user'] = "Non existing user"; $_['text_not_found'] = "Not found"; $_['text_not_running'] = "not running"; +$_['text_not_spam'] = "not spam"; $_['title_not_found'] = "Page not found"; $_['text_number_of_messages_in_quarantine'] = "Number of messages in the quarantine matching your search criteria"; $_['text_number_of_spam_messages_in_quarantine'] = "Number of spam messages in the quarantine matching your search criteria"; @@ -239,6 +240,8 @@ $_['text_simple'] = "Simple"; $_['text_simple_search'] = "Simple search"; $_['text_size'] = "Size"; $_['text_smtp_status'] = "SMTP status"; +$_['text_spam'] = "Spam"; +$_['text_spam2'] = "spam"; $_['text_statistics'] = "Statistics"; $_['text_status'] = "Status"; $_['text_subject'] = "Subject"; diff --git a/webui/language/hu/messages.iso-8859-2.php b/webui/language/hu/messages.iso-8859-2.php index 33d4185a..26f17edd 100644 --- a/webui/language/hu/messages.iso-8859-2.php +++ b/webui/language/hu/messages.iso-8859-2.php @@ -171,6 +171,7 @@ $_['text_non_existent_queue_directory'] = "A megadott queue k $_['text_non_existing_user'] = "Nem létező felhasználó"; $_['text_not_found'] = "Nincs találat"; $_['text_not_running'] = "nem fut"; +$_['text_not_spam'] = "nem spam"; $_['title_not_found'] = "Az oldal nem található"; $_['text_number_of_messages_in_quarantine'] = "A keresési feltételnek megfelelő üzenetek száma a karanténban"; $_['text_number_of_spam_messages_in_quarantine'] = "A keresési feltételnek megfelelő spam üzenetek száma a karanténban"; @@ -240,6 +241,8 @@ $_['text_simple'] = "Egyszer $_['text_simple_search'] = "Egyszerű keresés"; $_['text_size'] = "Méret"; $_['text_smtp_status'] = "SMTP státusz"; +$_['text_spam'] = "Spam"; +$_['text_spam2'] = "spam"; $_['text_statistics'] = "Statisztika"; $_['text_status'] = "Státusz"; $_['text_subject'] = "Tárgy"; diff --git a/webui/language/hu/messages.php b/webui/language/hu/messages.php index 7d732677..ee4e29c0 100644 --- a/webui/language/hu/messages.php +++ b/webui/language/hu/messages.php @@ -171,6 +171,7 @@ $_['text_non_existent_queue_directory'] = "A megadott queue könyvtár nem lĂ©te $_['text_non_existing_user'] = "Nem lĂ©tezĹ‘ felhasználĂł"; $_['text_not_found'] = "Nincs találat"; $_['text_not_running'] = "nem fut"; +$_['text_not_spam'] = "nem spam"; $_['title_not_found'] = "Az oldal nem találhatĂł"; $_['text_number_of_messages_in_quarantine'] = "A keresĂ©si feltĂ©telnek megfelelĹ‘ ĂĽzenetek száma a karantĂ©nban"; $_['text_number_of_spam_messages_in_quarantine'] = "A keresĂ©si feltĂ©telnek megfelelĹ‘ spam ĂĽzenetek száma a karantĂ©nban"; @@ -240,6 +241,8 @@ $_['text_simple'] = "Egyszerű"; $_['text_simple_search'] = "Egyszerű keresĂ©s"; $_['text_size'] = "MĂ©ret"; $_['text_smtp_status'] = "SMTP státusz"; +$_['text_spam'] = "Spam"; +$_['text_spam2'] = "spam"; $_['text_statistics'] = "Statisztika"; $_['text_status'] = "Státusz"; $_['text_subject'] = "Tárgy"; diff --git a/webui/model/policy/archiving.php b/webui/model/policy/archiving.php index 3d40b2f2..40112ede 100644 --- a/webui/model/policy/archiving.php +++ b/webui/model/policy/archiving.php @@ -22,7 +22,7 @@ class ModelPolicyArchiving extends Model { public function add_new_rule($data = array()) { - $query = $this->db->query("INSERT INTO " . TABLE_ARCHIVING_RULE . " (`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`) VALUES(?,?,?,?,?,?,?,?)", array($data['from'], $data['to'], $data['subject'], $data['_size'], $data['size'], $data['attachment_type'], $data['_attachment_size'], $data['attachment_size'])); + $query = $this->db->query("INSERT INTO " . TABLE_ARCHIVING_RULE . " (`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`) VALUES(?,?,?,?,?,?,?,?,?)", array($data['from'], $data['to'], $data['subject'], $data['_size'], $data['size'], $data['attachment_type'], $data['_attachment_size'], $data['attachment_size'], $data['spam'])); return $this->db->countAffected(); } diff --git a/webui/view/theme/default/templates/common/menu-admin.tpl b/webui/view/theme/default/templates/common/menu-admin.tpl index e9536ec8..b5a44ede 100644 --- a/webui/view/theme/default/templates/common/menu-admin.tpl +++ b/webui/view/theme/default/templates/common/menu-admin.tpl @@ -11,10 +11,11 @@
+
+
:
+
+ + +
+
+
 
@@ -58,11 +70,12 @@ -
+
+
@@ -74,6 +87,7 @@
+
0) { print $rule['_size']; ?>
0) { print $rule['_attachment_size']; ?>