From 987d27856a5dc625a6f0a9a03d86c86e3c4fc430 Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 27 Apr 2012 14:39:10 +0200 Subject: [PATCH] removed \n\n" CONFIGURE_PARAMS "\n" @@ -80,7 +80,8 @@ #define SQL_ARCHIVING_RULE_TABLE "archiving_rule" #define SQL_RETENTION_RULE_TABLE "retention_rule" #define SQL_COUNTER_TABLE "counter" -#define SQL_MESSAGES_VIEW "messages" +#define SQL_OPTION_TABLE "option" +#define SQL_MESSAGES_VIEW "v_messages" #define SQL_ATTACHMENTS_VIEW "v_attachment" diff --git a/src/pilerpurge.c b/src/pilerpurge.c index 41e2f4b4..70070308 100644 --- a/src/pilerpurge.c +++ b/src/pilerpurge.c @@ -21,12 +21,35 @@ extern int optind; int dryrun = 0; + +#define SQL_STMT_SELECT_PURGE_FROM_OPTION_TABLE "SELECT `value` FROM `" SQL_OPTION_TABLE "` WHERE `key`='enable_purge'" #define SQL_STMT_DELETE_FROM_META_TABLE "UPDATE `" SQL_METADATA_TABLE "` SET `deleted`=1 WHERE `id` IN (" #define SQL_STMT_DELETE_FROM_META_TABLE_BY_PILER_ID "UPDATE `" SQL_METADATA_TABLE "` SET `deleted`=1 WHERE `piler_id` IN ('" #define SQL_STMT_SELECT_NON_REFERENCED_ATTACHMENTS "SELECT `piler_id`, `attachment_id`, `i` FROM `" SQL_ATTACHMENTS_VIEW "` WHERE `refcount`=0 AND `piler_id` IN ('" #define SQL_STMT_DELETE_FROM_ATTACHMENT_TABLE "DELETE FROM `" SQL_ATTACHMENT_TABLE "` WHERE `id` IN (" +int is_purge_allowed(struct session_data *sdata, struct __config *cfg){ + int rc=0; + MYSQL_RES *res; + MYSQL_ROW row; + + if(mysql_real_query(&(sdata->mysql), SQL_STMT_SELECT_PURGE_FROM_OPTION_TABLE, strlen(SQL_STMT_SELECT_PURGE_FROM_OPTION_TABLE)) == 0){ + res = mysql_store_result(&(sdata->mysql)); + if(res){ + row = mysql_fetch_row(res); + if(row[0]){ + rc = atoi(row[0]); + } + + mysql_free_result(res); + } + } + + return rc; +} + + int remove_message_frame_files(char *s, char *update_meta_sql, struct session_data *sdata, struct __config *cfg){ char *p, puf[SMALLBUFSIZE], filename[SMALLBUFSIZE]; int n=0; @@ -318,11 +341,14 @@ int main(int argc, char **argv){ init_session_data(&sdata); - purged += purge_messages_without_attachment(&sdata, &cfg); - purged += purge_messages_with_attachments(&sdata, &cfg); - - printf("purged: %d\n", purged); + i = is_purge_allowed(&sdata, &cfg); + if(i == 1){ + purged += purge_messages_without_attachment(&sdata, &cfg); + purged += purge_messages_with_attachments(&sdata, &cfg); + printf("purged: %d\n", purged); + } + else printf("purge is not allowed by configuration, enable_purge=%d\n", i); mysql_close(&(sdata.mysql)); diff --git a/util/db-mysql.sql b/util/db-mysql.sql index fb82a834..94161674 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -18,8 +18,8 @@ create table if not exists `sph_index` ( `fromdomain` char(255) default null, `todomain` text(512) default null, `subject` text(512) default null, - `arrived` int not null, - `sent` int not null, + `arrived` int unsigned not null, + `sent` int unsigned not null, `body` text, `size` int default '0', `direction` int default 0, @@ -36,9 +36,9 @@ create table if not exists `metadata` ( `fromdomain` char(48) not null, `subject` text(512) default null, `spam` tinyint(1) default 0, - `arrived` int not null, - `sent` int not null, - `retained` int not null, + `arrived` int unsigned not null, + `sent` int unsigned not null, + `retained` int unsigned not null, `deleted` tinyint(1) default 0, `size` int default 0, `hlen` int default 0, @@ -74,8 +74,8 @@ create index `rcpt_idx` on `rcpt`(`id`); create index `rcpt_idx2` on `rcpt`(`to`); -drop view if exists `messages`; -create view `messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`); +drop view if exists `v_messages`; +create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`); drop table if exists `attachment`; @@ -156,6 +156,15 @@ create table if not exists `counter` ( insert into `counter` values(0, 0, 0, 0, 0); +drop table if exists `option`; +create table if not exists `option` ( + `key` char(64) not null, + `value` char(32) not null +) Engine=InnoDB; + +insert into `option` (`key`, `value`) values('enable_purge', '1'); + + drop table if exists `search`; create table if not exists `search` ( `email` char(128) not null, diff --git a/webui/config.php b/webui/config.php index c9ecc969..904667e8 100644 --- a/webui/config.php +++ b/webui/config.php @@ -15,8 +15,6 @@ define('ENABLE_REMOTE_IMAGES', '0'); define('ENABLE_ON_THE_FLY_VERIFICATION', 1); define('ENABLE_LDAP_IMPORT_FEATURE', 0); -define('HOLD_EMAIL', 0); - define('REMOTE_IMAGE_REPLACEMENT', '/view/theme/default/images/remote.gif'); define('ICON_ARROW_UP', '/view/theme/default/images/arrowup.gif'); define('ICON_ARROW_DOWN', '/view/theme/default/images/arrowdown.gif'); @@ -92,7 +90,8 @@ 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('TABLE_OPTION', 'option'); +define('VIEW_MESSAGES', 'v_messages'); define('SPHINX_DRIVER', 'sphinx'); define('SPHINX_DATABASE', 'sphinx'); @@ -131,6 +130,7 @@ define('AUDIT_HELPER_URL', SITE_URL . 'audit-helper.php'); define('SAVE_SEARCH_URL', SITE_URL . 'index.php?route=search/save'); define('SEARCH_TAG_URL', SITE_URL . 'index.php?route=search/tag'); +define('HEALTH_URL', SITE_URL . 'index.php?route=health/health'); define('HEALTH_WORKER_URL', SITE_URL . 'index.php?route=health/worker'); define('HEALTH_REFRESH', 60); define('HEALTH_RATIO', 80); diff --git a/webui/controller/health/health.php b/webui/controller/health/health.php index 5a219636..b25782f1 100644 --- a/webui/controller/health/health.php +++ b/webui/controller/health/health.php @@ -9,6 +9,7 @@ class ControllerHealthHealth extends Controller { $this->template = "health/health.tpl"; $this->layout = "common/layout-health"; + $this->load->model('health/health'); $request = Registry::get('request'); $language = Registry::get('language'); @@ -22,6 +23,14 @@ class ControllerHealthHealth extends Controller { $this->template = "common/error.tpl"; $this->data['errorstring'] = $this->data['text_you_are_not_admin']; } + else { + if(isset($_GET['toggle_enable_purge'])) { + $this->model_health_health->toggle_option('enable_purge'); + header("Location: " . HEALTH_URL); + exit; + } + + } $this->render(); diff --git a/webui/controller/health/worker.php b/webui/controller/health/worker.php index fc677bbf..8e0ed7b6 100644 --- a/webui/controller/health/worker.php +++ b/webui/controller/health/worker.php @@ -78,6 +78,8 @@ class ControllerHealthWorker extends Controller { $this->data['sysinfo'] = $this->model_health_health->sysinfo(); + $this->data['options'] = $this->model_health_health->get_options(); + $this->render(); } diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index 55c84774..ec25cc34 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -59,8 +59,10 @@ $_['text_deliver_and_train_selected_messages'] = "Deliver and train selected mes $_['text_deliver_and_train_selected_messages_as_ham'] = "Deliver and train selected messages AS HAM"; $_['text_deliver_selected_messages'] = "Deliver selected messages"; $_['text_description'] = "Description"; -$_['text_disk_usage'] = "Disk usage"; $_['text_direction'] = "Direction"; +$_['text_disk_usage'] = "Disk usage"; +$_['text_disable'] = "Disable"; +$_['text_disabled'] = "disabled"; $_['text_dn_asterisk_means_skip_sync'] = "Asterisk (*) means this user entry will be not part of AD synchronisation"; $_['text_domain'] = "Domain"; $_['text_domains'] = "Domain(s)"; @@ -76,6 +78,8 @@ $_['text_email_aliases'] = "Email aliases"; $_['text_email_in_unknown_domain'] = "Email address is in an unknown domain"; $_['text_empty_search_criteria'] = "'Empty criteria'"; $_['text_empty_search_result'] = "Empty search result"; +$_['text_enable'] = "Enable"; +$_['text_enabled'] = "enabled"; $_['text_enter_search_terms'] = "Enter your search terms"; $_['text_error'] = "Error"; $_['text_exact_domain_name_or_email_address'] = "exact domain name or email address"; @@ -187,6 +191,7 @@ $_['text_password_again'] = "Password again"; $_['text_password_changed'] = "Password changed"; $_['text_password_mismatch'] = "Password mismatch"; $_['text_page_length'] = "Page length"; +$_['text_periodic_purge'] = "Periodic purge"; $_['text_policy'] = "Policy"; $_['text_policy_group'] = "Policy group"; $_['text_policy_name'] = "Policy name"; @@ -257,6 +262,7 @@ $_['text_successfully_trained'] = "Successfully trained"; $_['text_successfully_updated'] = "Successfully modified"; $_['text_swap_usage'] = "Swap usage"; +$_['text_tag_search_results'] = "Tag search results"; $_['text_tags'] = "Tags"; $_['text_text'] = "Text"; $_['text_text2'] = "text"; diff --git a/webui/language/hu/messages.iso-8859-2.php b/webui/language/hu/messages.iso-8859-2.php index 08bf4d91..75101aaf 100644 --- a/webui/language/hu/messages.iso-8859-2.php +++ b/webui/language/hu/messages.iso-8859-2.php @@ -59,8 +59,10 @@ $_['text_deliver_and_train_selected_messages'] = "Kiv $_['text_deliver_and_train_selected_messages_as_ham'] = "Kiválasztott üzenetek tanítása JÓ LEVÉLKÉNT, és kézbesítése"; $_['text_deliver_selected_messages'] = "Kiválasztott üzenetek kézbesítése"; $_['text_description'] = "Leírás"; -$_['text_disk_usage'] = "Diszk használat"; $_['text_direction'] = "Irány"; +$_['text_disable'] = "Letilt"; +$_['text_disabled'] = "letiltva"; +$_['text_disk_usage'] = "Diszk használat"; $_['text_dn_asterisk_means_skip_sync'] = "A csillag (*) azt jelenti, hogy ez a felhasználó nem része az AD szerverről szinkronizálásnak"; $_['text_domain'] = "Domain"; $_['text_domains'] = "Domain(ek)"; @@ -76,6 +78,8 @@ $_['text_email_aliases'] = "Email $_['text_email_in_unknown_domain'] = "Az email cím ismeretlen domainben van"; $_['text_empty_search_criteria'] = "'Üres feltétel'"; $_['text_empty_search_result'] = "Nincs találat a keresésre"; +$_['text_enable'] = "Engedélyez"; +$_['text_enabled'] = "engedélyezve"; $_['text_enter_search_terms'] = "Írja be a keresési feltételeket"; $_['text_error'] = "Hiba"; $_['text_exact_domain_name_or_email_address'] = "pontos domainnév vagy email cím"; @@ -188,6 +192,7 @@ $_['text_password_again'] = "Jelsz $_['text_password_changed'] = "Jelszó megváltozott"; $_['text_password_mismatch'] = "A két jelszó nem egyezik meg"; $_['text_page_length'] = "Lap méret"; +$_['text_periodic_purge'] = "Periódikus levéltörlés"; $_['text_policy'] = "Házirend"; $_['text_policy_group'] = "Házirend azonosító"; $_['text_policy_name'] = "Házirend neve"; @@ -258,6 +263,7 @@ $_['text_successfully_trained'] = "Sikeresen tan $_['text_successfully_updated'] = "Sikeresen módosítva"; $_['text_swap_usage'] = "Swap használat"; +$_['text_tag_search_results'] = "Keresés eredményének címkézése"; $_['text_tags'] = "Címkék"; $_['text_text'] = "Szöveg"; $_['text_text2'] = "szöveg"; diff --git a/webui/language/hu/messages.php b/webui/language/hu/messages.php index 1f4dfdf0..75311a09 100644 --- a/webui/language/hu/messages.php +++ b/webui/language/hu/messages.php @@ -59,8 +59,10 @@ $_['text_deliver_and_train_selected_messages'] = "Kiválasztott ĂĽzenetek tanĂ­t $_['text_deliver_and_train_selected_messages_as_ham'] = "Kiválasztott ĂĽzenetek tanĂ­tása JĂ“ LEVÉLKÉNT, Ă©s kĂ©zbesĂ­tĂ©se"; $_['text_deliver_selected_messages'] = "Kiválasztott ĂĽzenetek kĂ©zbesĂ­tĂ©se"; $_['text_description'] = "LeĂ­rás"; -$_['text_disk_usage'] = "Diszk használat"; $_['text_direction'] = "Irány"; +$_['text_disable'] = "Letilt"; +$_['text_disabled'] = "letiltva"; +$_['text_disk_usage'] = "Diszk használat"; $_['text_dn_asterisk_means_skip_sync'] = "A csillag (*) azt jelenti, hogy ez a felhasználĂł nem rĂ©sze az AD szerverrĹ‘l szinkronizálásnak"; $_['text_domain'] = "Domain"; $_['text_domains'] = "Domain(ek)"; @@ -76,6 +78,8 @@ $_['text_email_aliases'] = "Email álcĂ­mek"; $_['text_email_in_unknown_domain'] = "Az email cĂ­m ismeretlen domainben van"; $_['text_empty_search_criteria'] = "'Ăśres feltĂ©tel'"; $_['text_empty_search_result'] = "Nincs találat a keresĂ©sre"; +$_['text_enable'] = "EngedĂ©lyez"; +$_['text_enabled'] = "engedĂ©lyezve"; $_['text_enter_search_terms'] = "ĂŤrja be a keresĂ©si feltĂ©teleket"; $_['text_error'] = "Hiba"; $_['text_exact_domain_name_or_email_address'] = "pontos domainnĂ©v vagy email cĂ­m"; @@ -188,6 +192,7 @@ $_['text_password_again'] = "JelszĂł ismĂ©t"; $_['text_password_changed'] = "JelszĂł megváltozott"; $_['text_password_mismatch'] = "A kĂ©t jelszĂł nem egyezik meg"; $_['text_page_length'] = "Lap mĂ©ret"; +$_['text_periodic_purge'] = "PeriĂłdikus levĂ©ltörlĂ©s"; $_['text_policy'] = "Házirend"; $_['text_policy_group'] = "Házirend azonosĂ­tĂł"; $_['text_policy_name'] = "Házirend neve"; @@ -258,6 +263,7 @@ $_['text_successfully_trained'] = "Sikeresen tanĂ­tva"; $_['text_successfully_updated'] = "Sikeresen mĂłdosĂ­tva"; $_['text_swap_usage'] = "Swap használat"; +$_['text_tag_search_results'] = "KeresĂ©s eredmĂ©nyĂ©nek cĂ­mkĂ©zĂ©se"; $_['text_tags'] = "CĂ­mkĂ©k"; $_['text_text'] = "Szöveg"; $_['text_text2'] = "szöveg"; diff --git a/webui/model/health/health.php b/webui/model/health/health.php index 66e4b022..9a31b255 100644 --- a/webui/model/health/health.php +++ b/webui/model/health/health.php @@ -108,6 +108,36 @@ class ModelHealthHealth extends Model { } + public function get_options() { + $data = array(); + + $query = $this->db->query("SELECT * FROM `" . TABLE_OPTION . "`"); + if(isset($query->rows)) { + foreach ($query->rows as $q) { + $data[$q['key']] = $q['value']; + } + } + + return $data; + } + + + public function toggle_option($option = '') { + $value = 0; + + $query = $this->db->query("SELECT `value` FROM `" . TABLE_OPTION . "` WHERE `key`=?", array($option)); + + if(isset($query->row['value'])) { + if($query->row['value'] == 0) { $value = 1; } + else { $value = 0; } + + $query = $this->db->query("UPDATE `" . TABLE_OPTION . "` SET `value`=? WHERE `key`=?", array($value, $option)); + + } + + } + + } diff --git a/webui/model/search/search.php b/webui/model/search/search.php index edb89451..f59299b6 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -361,7 +361,10 @@ class ModelSearchSearch extends Model { if(isset($query->rows)) { - $tags = $this->db->query("SELECT `id`, `tag` FROM `" . TABLE_TAG . "` WHERE `id` IN ($q)", $ids); + array_unshift($ids, (int)$_SESSION['uid']); + + $tags = $this->db->query("SELECT `id`, `tag` FROM `" . TABLE_TAG . "` WHERE `uid`=? AND `id` IN ($q)", $ids); + foreach ($tags->rows as $t) { $tag[$t['id']] = $t['tag']; } @@ -494,18 +497,8 @@ class ModelSearchSearch extends Model { } - public function remove_message($id = '') { - if($id == '') { return 0; } - - if(Registry::get('admin_user') == 0) { return 0; } - - $query = $this->db->query("UPDATE " . TABLE_META . " SET deleted=1 WHERE piler_id=?", array($id)); - - return $this->db->countAffected(); - } - - private function fix_email_address_for_sphinx($email = '') { + $email = preg_replace("/\|@/", "|", $email); return preg_replace("/[\@\.\+\-]/", "X", $email); } diff --git a/webui/view/theme/default/templates/audit/helper.tpl b/webui/view/theme/default/templates/audit/helper.tpl index eaaf0269..1e6aa1bb 100644 --- a/webui/view/theme/default/templates/audit/helper.tpl +++ b/webui/view/theme/default/templates/audit/helper.tpl @@ -32,30 +32,30 @@ 0){ ?>
- - + +
- - + +
- - + +
- - + +
- - + +
@@ -63,7 +63,7 @@
-
+
diff --git a/webui/view/theme/default/templates/health/worker.tpl b/webui/view/theme/default/templates/health/worker.tpl index 9b6cfcaa..7ea4d307 100644 --- a/webui/view/theme/default/templates/health/worker.tpl +++ b/webui/view/theme/default/templates/health/worker.tpl @@ -45,7 +45,7 @@
:
-
()
()
()
+
()
()
()
@@ -68,6 +68,12 @@
%
+
+
+
. .
+
+ +
diff --git a/webui/view/theme/default/templates/message/headers.tpl b/webui/view/theme/default/templates/message/headers.tpl index 9d0b42a4..905bd37e 100644 --- a/webui/view/theme/default/templates/message/headers.tpl +++ b/webui/view/theme/default/templates/message/headers.tpl @@ -11,9 +11,6 @@ | | - - | -

diff --git a/webui/view/theme/default/templates/message/restore.tpl b/webui/view/theme/default/templates/message/restore.tpl index 226a2e08..a1b203c7 100644 --- a/webui/view/theme/default/templates/message/restore.tpl +++ b/webui/view/theme/default/templates/message/restore.tpl @@ -11,9 +11,6 @@ | | - - | -

diff --git a/webui/view/theme/default/templates/message/view.tpl b/webui/view/theme/default/templates/message/view.tpl index 642af4e9..59b222d9 100644 --- a/webui/view/theme/default/templates/message/view.tpl +++ b/webui/view/theme/default/templates/message/view.tpl @@ -11,9 +11,6 @@ | | - -| -


diff --git a/webui/view/theme/default/templates/search/helper.tpl b/webui/view/theme/default/templates/search/helper.tpl index da7b016f..3b1ca868 100644 --- a/webui/view/theme/default/templates/search/helper.tpl +++ b/webui/view/theme/default/templates/search/helper.tpl @@ -20,7 +20,7 @@ - Tag search results: + :
  @@ -39,23 +39,23 @@
 
- - + +
- - + +
- - + +
- - + +
 
 
@@ -63,7 +63,7 @@
 
-
+
diff --git a/webui/view/theme/default/templates/search/search.tpl b/webui/view/theme/default/templates/search/search.tpl index 44da483c..4392e3df 100644 --- a/webui/view/theme/default/templates/search/search.tpl +++ b/webui/view/theme/default/templates/search/search.tpl @@ -35,7 +35,7 @@
- +