From 82cf1e84254fc9023b4871ba40967cc4966c9452 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Wed, 21 Jan 2015 04:13:19 -0500 Subject: [PATCH] Merge branch 'renky/ispconfig3-master' --- install/tpl/system.ini.master | 4 remoting_client/API-docs/mail_user_backup.html | 26 +++++ interface/web/mail/lib/remote.conf.php | 1 remoting_client/API-docs/navigation.html | 2 install/sql/ispconfig3.sql | 4 interface/web/admin/lib/lang/es_system_config.lng | 1 interface/web/admin/lib/lang/id_system_config.lng | 1 install/sql/incremental/upd_dev_collection.sql | 2 interface/web/admin/lib/lang/cz_system_config.lng | 1 interface/web/admin/lib/lang/se_system_config.lng | 1 interface/web/admin/lib/lang/sk_system_config.lng | 1 interface/web/admin/lib/lang/ja_system_config.lng | 1 server/lib/classes/cron.d/500-backup.inc.php | 23 +++- interface/web/admin/templates/system_config_sites_edit.htm | 7 + interface/web/mail/templates/mail_user_backup_list.htm | 8 - interface/web/admin/lib/lang/bg_system_config.lng | 1 interface/web/admin/lib/lang/pt_system_config.lng | 1 server/plugins-available/backup_plugin.inc.php | 41 +++++-- interface/web/admin/lib/lang/en_system_config.lng | 1 interface/web/admin/lib/lang/it_system_config.lng | 1 interface/web/admin/lib/lang/de_system_config.lng | 1 interface/web/admin/lib/lang/ru_system_config.lng | 1 server/lib/classes/cron.d/500-backup_mail.inc.php | 39 ++++++- interface/lib/classes/remote.d/mail.inc.php | 65 +++++++++++++ interface/web/admin/form/system_config.tform.php | 6 + interface/web/admin/lib/lang/tr_system_config.lng | 1 interface/web/admin/lib/lang/hr_system_config.lng | 1 interface/web/admin/lib/lang/el_system_config.lng | 1 interface/web/admin/lib/lang/fi_system_config.lng | 1 interface/web/admin/lib/lang/pl_system_config.lng | 1 interface/web/admin/lib/lang/ro_system_config.lng | 1 remoting_client/API-docs/mail_user_backup_list.html | 26 +++++ interface/web/admin/lib/lang/fr_system_config.lng | 1 interface/web/admin/lib/lang/ar_system_config.lng | 1 interface/web/admin/lib/lang/hu_system_config.lng | 1 interface/web/admin/lib/lang/nl_system_config.lng | 1 interface/lib/classes/plugin_backuplist_mail.inc.php | 12 + interface/web/admin/lib/lang/br_system_config.lng | 1 38 files changed, 251 insertions(+), 38 deletions(-) diff --git a/install/sql/incremental/upd_dev_collection.sql b/install/sql/incremental/upd_dev_collection.sql index 87eaa09..aa23b17 100644 --- a/install/sql/incremental/upd_dev_collection.sql +++ b/install/sql/incremental/upd_dev_collection.sql @@ -32,3 +32,5 @@ MX|{DOMAIN}.|mail.{DOMAIN}.|10|3600 TXT|{DOMAIN}.|v=spf1 mx a ~all|0|3600' WHERE `dns_template`.`template_id` = 1; +ALTER TABLE `mail_backup` CHANGE `filesize` `filesize` VARCHAR(20) NOT NULL DEFAULT ''; +ALTER TABLE `web_backup` CHANGE `filesize` `filesize` VARCHAR(20) NOT NULL DEFAULT ''; diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 6c57ce0..8b79165 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -703,7 +703,7 @@ `backup_mode` varchar(64) NOT NULL DEFAULT '', `tstamp` int(10) unsigned NOT NULL DEFAULT '0', `filename` varchar(255) NOT NULL DEFAULT '', - `filesize` VARCHAR(10) NOT NULL DEFAULT '', + `filesize` VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (`backup_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -1746,7 +1746,7 @@ `backup_mode` varchar(64) NOT NULL DEFAULT '', `tstamp` int(10) unsigned NOT NULL DEFAULT '0', `filename` varchar(255) NOT NULL DEFAULT '', - `filesize` VARCHAR(10) NOT NULL DEFAULT '', + `filesize` VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (`backup_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/install/tpl/system.ini.master b/install/tpl/system.ini.master index f1a1bc9..74ab068 100644 --- a/install/tpl/system.ini.master +++ b/install/tpl/system.ini.master @@ -23,9 +23,13 @@ dblist_phpmyadmin_link=y phpmyadmin_url=/phpmyadmin webftp_url= +vhost_subdomains=n +vhost_aliasdomains=n client_username_web_check_disabled=n +backups_include_into_web_quota=n reseller_can_use_options=n + [tools] [domains] diff --git a/interface/lib/classes/plugin_backuplist_mail.inc.php b/interface/lib/classes/plugin_backuplist_mail.inc.php index 5bef570..8474283 100644 --- a/interface/lib/classes/plugin_backuplist_mail.inc.php +++ b/interface/lib/classes/plugin_backuplist_mail.inc.php @@ -39,6 +39,9 @@ function onShow() { global $app; + + $app->uses('functions'); + $listTpl = new tpl; $listTpl->newTemplate('templates/mail_user_backup_list.htm'); @@ -53,7 +56,7 @@ if(isset($_GET['backup_action'])) { $backup_id = $app->functions->intval($_GET['backup_id']); /* - if($_GET['backup_action'] == 'download' && $backup_id > 0) { + if($_GET['backup_action'] == 'download_mail' && $backup_id > 0) { $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'"; $tmp = $app->db->queryOneRecord($sql); if($tmp['number'] == 0) { @@ -73,8 +76,8 @@ } } */ - if($_GET['backup_action'] == 'restore' && $backup_id > 0) { - $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore' AND action_param = '$backup_id'"; + if($_GET['backup_action'] == 'restore_mail' && $backup_id > 0) { + $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore_mail' AND action_param = '$backup_id'"; $tmp = $app->db->queryOneRecord($sql); if($tmp['number'] == 0) { $message .= $wb['restore_info_txt']; @@ -82,7 +85,7 @@ "VALUES (". (int)$this->form->dataRecord['server_id'] . ", " . time() . ", " . - "'backup_restore', " . + "'backup_restore_mail', " . "'".$backup_id."', " . "'pending', " . "''" . @@ -105,6 +108,7 @@ $rec["bgcolor"] = $bgcolor; $rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']); $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])]; + $rec['filesize'] = $app->functions->formatBytes($rec['filesize']); $records_new[] = $rec; } } diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php index e579fb6..29ff0d8 100644 --- a/interface/lib/classes/remote.d/mail.inc.php +++ b/interface/lib/classes/remote.d/mail.inc.php @@ -309,6 +309,71 @@ // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this); return $affected_rows; } + + // Mail backup list function by Dominik M�ller, info@profi-webdesign.net + public function mail_user_backup_list($session_id, $primary_id = null) + { + global $app; + + if(!$this->checkPerm($session_id, 'mail_user_backup')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + if ($site_id != null) { + $sql = "SELECT * FROM mail_backup WHERE parent_domain_id = ".$app->functions->intval($site_id); + } + else { + $sql = "SELECT * FROM mail_backup"; + } + + $result = $app->db->queryAllRecords($sql); + return $result; + } + + // Mail backup restore/download functions by Dominik M�ller, info@profi-webdesign.net + public function mail_user_backup($session_id, $primary_id, $action_type) + { + global $app; + + if(!$this->checkPerm($session_id, 'mail_user_backup')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + //*Set variables + $backup_record = $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`='$primary_id'"); + $server_id = $backup_record['server_id']; + + //*Set default action state + $action_state = "pending"; + $tstamp = time(); + + //* Basic validation of variables + if ($server_id <= 0) { + $this->server->fault('invalid_backup_id', "Invalid or non existant backup_id $primary_id"); + return false; + } + + if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail') { + $this->server->fault('invalid_action', "Invalid action_type $action_type"); + return false; + } + + //* Validate instance + $instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`='$primary_id' and `action_type`='$action_type' and `action_state`='pending'"); + if ($instance_record['action_id'] >= 1) { + $this->server->fault('duplicate_action', "There is already a pending $action_type action"); + return false; + } + + //* Save the record + if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = '$server_id', `tstamp` = '$tstamp', `action_type` = '$action_type', `action_param` = '$primary_id', `action_state` = '$action_state'")) { + return true; + } else { + return false; + } + } //* Get alias details public function mail_alias_get($session_id, $primary_id) diff --git a/interface/web/admin/form/system_config.tform.php b/interface/web/admin/form/system_config.tform.php index 28aa42b..fabc180 100644 --- a/interface/web/admin/form/system_config.tform.php +++ b/interface/web/admin/form/system_config.tform.php @@ -166,6 +166,12 @@ 'default' => 'n', 'value' => array(0 => 'n', 1 => 'y') ), + 'backups_include_into_web_quota' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), 'reseller_can_use_options' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', diff --git a/interface/web/admin/lib/lang/ar_system_config.lng b/interface/web/admin/lib/lang/ar_system_config.lng index 766c55b..61f7a79 100644 --- a/interface/web/admin/lib/lang/ar_system_config.lng +++ b/interface/web/admin/lib/lang/ar_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/bg_system_config.lng b/interface/web/admin/lib/lang/bg_system_config.lng index cde9ab7..a88c2ce 100644 --- a/interface/web/admin/lib/lang/bg_system_config.lng +++ b/interface/web/admin/lib/lang/bg_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/br_system_config.lng b/interface/web/admin/lib/lang/br_system_config.lng index c0caf05..2a72018 100644 --- a/interface/web/admin/lib/lang/br_system_config.lng +++ b/interface/web/admin/lib/lang/br_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/cz_system_config.lng b/interface/web/admin/lib/lang/cz_system_config.lng index 13a202f..ec1fae3 100644 --- a/interface/web/admin/lib/lang/cz_system_config.lng +++ b/interface/web/admin/lib/lang/cz_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Použití indikátoru zatížení'; $wb['f5_to_reload_js_txt'] = 'Pokud vypnete tuto volbu, zřejmě budete muset používat klávesu F5, aby internetový prohlížeč znovu načetl JavaScript knihovny nebo budete muset ručně vyprázdňovat mezipaměť (cache) vašeho internetového prohlížeče.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show Autoresponder tab in Mailbox detail'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show Mail Filter tab in Mailbox detail'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show Custom Rules tab in Mailbox detail'; diff --git a/interface/web/admin/lib/lang/de_system_config.lng b/interface/web/admin/lib/lang/de_system_config.lng index b0f612a..862fb56 100644 --- a/interface/web/admin/lib/lang/de_system_config.lng +++ b/interface/web/admin/lib/lang/de_system_config.lng @@ -48,6 +48,7 @@ $wb['f5_to_reload_js_txt'] = 'Wenn Sie den Wert ändern, müssen Sie F5 drücken, damit der Browser die JavaScript Bibliotheken neu lädt, oder Ihren Browser Cache leeren.'; $wb['phpmyadmin_url_error_regex'] = 'Falsche phpMyAdmin URL'; $wb['client_username_web_check_disabled_txt'] = 'Deaktiviere die Kunden Benutzernamen Überprüfung für den Begriff <b>web<b>.'; +$wb['backups_include_into_web_quota_txt'] = 'Backups in Web Quota hinzuzählen.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Zeige Autoresponder Reiter in E-Mail Kontodetails'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Zeige E-Mail Filter Reiter in E-Mail Kontodetails'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Zeige Benutzerregel Reiter in E-Mail Kontodetails'; diff --git a/interface/web/admin/lib/lang/el_system_config.lng b/interface/web/admin/lib/lang/el_system_config.lng index fa2cfee..aa97d1e 100644 --- a/interface/web/admin/lib/lang/el_system_config.lng +++ b/interface/web/admin/lib/lang/el_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Χρήση Load Indicator (ενδεικτή φόρτωσης)'; $wb['f5_to_reload_js_txt'] = 'Αν το αλλάξετε, ίσως πρέπει να πατήσετε το F5 για να κάνετε τον φυλλομετρητη να ξαναφορτώσει τις βιβλιοθήκες JavaScript ή να αδείασετε την cache του φυλλομετρητή.'; $wb['client_username_web_check_disabled_txt'] = 'Απενεργοποίηση ελέγχου στο όνομα χρήστη για την λέξη \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Εμφάνιση της καρτέλας Αυτόματης Απάντησης στις λεπτομέρειες του λογαριασμού mail'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Εμφάνιση της καρτέλας Φίλτρα mail στις λεπτομέρειες του λογαριασμού mail'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Εμφάνιση της καρτέλας Προσαρμοσμένοι Κανόνες στις λεπτομέρειες του λογαριασμού mail'; diff --git a/interface/web/admin/lib/lang/en_system_config.lng b/interface/web/admin/lib/lang/en_system_config.lng index 3fa210f..f446bb3 100644 --- a/interface/web/admin/lib/lang/en_system_config.lng +++ b/interface/web/admin/lib/lang/en_system_config.lng @@ -51,6 +51,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/es_system_config.lng b/interface/web/admin/lib/lang/es_system_config.lng index 41e61bf..e51736b 100644 --- a/interface/web/admin/lib/lang/es_system_config.lng +++ b/interface/web/admin/lib/lang/es_system_config.lng @@ -46,6 +46,7 @@ $wb['use_loadindicator_txt'] = 'Usar indicador de carga'; $wb['f5_to_reload_js_txt'] = 'Si cambias esto, podrías tener que pulsar F5 para que tu navegador recargue las librerías JavaScript o vacíar la caché del navegador.'; $wb['client_username_web_check_disabled_txt'] = "Desactivar comprobación de la palabra 'web' en el nombre de cliente."; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Mostrar pestaña autoresponder en los detalles de la cuenta de correo'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Mostrar pestaña filtro de correo en los detalles de la cuenta de correo'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Mostrar pestaña filtros personalizados en los detalles de la cuenta de correo'; diff --git a/interface/web/admin/lib/lang/fi_system_config.lng b/interface/web/admin/lib/lang/fi_system_config.lng index 7d840b5..6e1239e 100755 --- a/interface/web/admin/lib/lang/fi_system_config.lng +++ b/interface/web/admin/lib/lang/fi_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/fr_system_config.lng b/interface/web/admin/lib/lang/fr_system_config.lng index b6db6d7..1fb0643 100644 --- a/interface/web/admin/lib/lang/fr_system_config.lng +++ b/interface/web/admin/lib/lang/fr_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/hr_system_config.lng b/interface/web/admin/lib/lang/hr_system_config.lng index fe9b89f..3827e3a 100644 --- a/interface/web/admin/lib/lang/hr_system_config.lng +++ b/interface/web/admin/lib/lang/hr_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/hu_system_config.lng b/interface/web/admin/lib/lang/hu_system_config.lng index d6d6224..37ca447 100644 --- a/interface/web/admin/lib/lang/hu_system_config.lng +++ b/interface/web/admin/lib/lang/hu_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/id_system_config.lng b/interface/web/admin/lib/lang/id_system_config.lng index 7baf017..d4f2625 100644 --- a/interface/web/admin/lib/lang/id_system_config.lng +++ b/interface/web/admin/lib/lang/id_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/it_system_config.lng b/interface/web/admin/lib/lang/it_system_config.lng index 9f151ca..9d00c8d 100644 --- a/interface/web/admin/lib/lang/it_system_config.lng +++ b/interface/web/admin/lib/lang/it_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/ja_system_config.lng b/interface/web/admin/lib/lang/ja_system_config.lng index 7800e3f..e81768d 100644 --- a/interface/web/admin/lib/lang/ja_system_config.lng +++ b/interface/web/admin/lib/lang/ja_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/nl_system_config.lng b/interface/web/admin/lib/lang/nl_system_config.lng index 07d5bff..6f1a6fb 100644 --- a/interface/web/admin/lib/lang/nl_system_config.lng +++ b/interface/web/admin/lib/lang/nl_system_config.lng @@ -51,6 +51,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/pl_system_config.lng b/interface/web/admin/lib/lang/pl_system_config.lng index 792fb89..4023906 100644 --- a/interface/web/admin/lib/lang/pl_system_config.lng +++ b/interface/web/admin/lib/lang/pl_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Użyj wskaźnika ładowania'; $wb['f5_to_reload_js_txt'] = 'Jeżeli zmienisz to, możesz potrzebować wcisnąć F5 lub wyczyścić cache aby przeglądarka przeładowała biblioteki JavaScript.'; $wb['client_username_web_check_disabled_txt'] = 'Wyłącz sprawdzanie nazwy klienta w poszukiwaniu słowa -web-.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Pokaż zakładkę autorespondera w szczegółach konta email.'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Pokaż zakładkę filtra email w szczegółach konta email.'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Pokaż zakładkę własnych filtrów email w szczegółach konta email.'; diff --git a/interface/web/admin/lib/lang/pt_system_config.lng b/interface/web/admin/lib/lang/pt_system_config.lng index e79ae6a..30d73f4 100644 --- a/interface/web/admin/lib/lang/pt_system_config.lng +++ b/interface/web/admin/lib/lang/pt_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/ro_system_config.lng b/interface/web/admin/lib/lang/ro_system_config.lng index a56ea01..d2d9193 100644 --- a/interface/web/admin/lib/lang/ro_system_config.lng +++ b/interface/web/admin/lib/lang/ro_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/ru_system_config.lng b/interface/web/admin/lib/lang/ru_system_config.lng index fdfb9d0..a3a610c 100644 --- a/interface/web/admin/lib/lang/ru_system_config.lng +++ b/interface/web/admin/lib/lang/ru_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/se_system_config.lng b/interface/web/admin/lib/lang/se_system_config.lng index 97850cd..0a6a60b 100644 --- a/interface/web/admin/lib/lang/se_system_config.lng +++ b/interface/web/admin/lib/lang/se_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Använd laddningsindikator'; $wb['f5_to_reload_js_txt'] = 'Om du ändrar detta kan du behöva trycka F5 för att ladda om javascript, eller rensa din webbläsarcache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Visa autosvarsfliken vid detaljerna för epostkonto'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Visa epostfilterfliken vid detaljerna för epostkonto'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/sk_system_config.lng b/interface/web/admin/lib/lang/sk_system_config.lng index 8a51291..0a4c0ad 100644 --- a/interface/web/admin/lib/lang/sk_system_config.lng +++ b/interface/web/admin/lib/lang/sk_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/tr_system_config.lng b/interface/web/admin/lib/lang/tr_system_config.lng index 621f821..d652b91 100644 --- a/interface/web/admin/lib/lang/tr_system_config.lng +++ b/interface/web/admin/lib/lang/tr_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/templates/system_config_sites_edit.htm b/interface/web/admin/templates/system_config_sites_edit.htm index ea04006..711d433 100644 --- a/interface/web/admin/templates/system_config_sites_edit.htm +++ b/interface/web/admin/templates/system_config_sites_edit.htm @@ -52,6 +52,12 @@ </div> </div> <div class="form-group"> + <label class="col-sm-3 control-label">{tmpl_var name='backups_include_into_web_quota_txt'}</label> + <div class="col-sm-9"> + {tmpl_var name='backups_include_into_web_quota'} + </div> + </div> + <div class="form-group"> <label class="col-sm-3 control-label">{tmpl_var name='reseller_can_use_options_txt'}</label> <div class="col-sm-9"> {tmpl_var name='reseller_can_use_options'} @@ -69,7 +75,6 @@ {tmpl_var name='default_dbserver'} </select></div> </div> - <input type="hidden" name="id" value="{tmpl_var name='id'}"> diff --git a/interface/web/mail/lib/remote.conf.php b/interface/web/mail/lib/remote.conf.php index 5ddec4e..ae03e99 100644 --- a/interface/web/mail/lib/remote.conf.php +++ b/interface/web/mail/lib/remote.conf.php @@ -17,6 +17,7 @@ $function_list['mail_spamfilter_whitelist_get,mail_spamfilter_whitelist_add,mail_spamfilter_whitelist_update,mail_spamfilter_whitelist_delete'] = 'Mail spamfilter whitelist functions'; $function_list['mail_spamfilter_blacklist_get,mail_spamfilter_blacklist_add,mail_spamfilter_blacklist_update,mail_spamfilter_blacklist_delete'] = 'Mail spamfilter blacklist functions'; $function_list['mail_user_filter_get,mail_user_filter_add,mail_user_filter_update,mail_user_filter_delete'] = 'Mail user filter functions'; +$function_list['mail_user_backup'] = 'Mail Backup functions'; $function_list['mail_filter_get,mail_filter_add,mail_filter_update,mail_filter_delete'] = 'Mail filter functions'; diff --git a/interface/web/mail/templates/mail_user_backup_list.htm b/interface/web/mail/templates/mail_user_backup_list.htm index e5fd020..87091b4 100644 --- a/interface/web/mail/templates/mail_user_backup_list.htm +++ b/interface/web/mail/templates/mail_user_backup_list.htm @@ -26,9 +26,7 @@ <td>{tmpl_var name="filesize"}</td> <td class="text-right"> <div class="buttons"> - <button class="btn btn-default formbutton-default" type="button" onclick="ISPConfig.confirm_action('mail/mail_user_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=restore&backup_id={tmpl_var name='backup_id'}','{tmpl_var name='restore_confirm_txt'}');">{tmpl_var name="restore_backup_txt"}</button> -<!-- <button class="btn btn-default formbutton-default" type="button" data-load-content="mail/mail_user_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=download&backup_id={tmpl_var name='backup_id'}">{tmpl_var name="download_backup_txt"}</button> ---> + <button class="btn btn-default formbutton-default" type="button" onclick="ISPConfig.confirm_action('mail/mail_user_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=restore_mail&backup_id={tmpl_var name='backup_id'}','{tmpl_var name='restore_confirm_txt'}');">{tmpl_var name="restore_backup_txt"}</button> </div> </td> </tr> @@ -40,6 +38,4 @@ </tmpl_unless> </tbody> </table> -</div> - - </div> +</div> \ No newline at end of file diff --git a/remoting_client/API-docs/mail_user_backup.html b/remoting_client/API-docs/mail_user_backup.html new file mode 100644 index 0000000..896ed92 --- /dev/null +++ b/remoting_client/API-docs/mail_user_backup.html @@ -0,0 +1,26 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html><head><title>ISCPConfig 3 API Functions</title> + + + + + + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <link rel="stylesheet" type="text/css" href="definitionen.css"> + <style type="text/css"> + </style></head> + +<body> +<div style="padding:40px"> +<h1>mail_user_backup(<span class="var">$session_id</span>, <span class="var">$primary_id</span>, <span class="var">$action_type</span>);</h1> +<br> +<p class="headgrp">Description: </p> +<p class="margin"> Adds a new backup / restore task. Please note: <em>$action_type</em> <!-- is either <em>backup_download_mail</em> or --> must be <em>backup_restore_mail</em></p> +<br> +<p class="headgrp">Input Variables: </p> +<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span>, <span class="var">$action_type</span></p> +<p class="headgrp">Output: </p> +<p class="margin"> Returns <em>TRUE</em> if successfull or <em>FALSE</em> if failure.</p> +</div> + +</body></html> diff --git a/remoting_client/API-docs/mail_user_backup_list.html b/remoting_client/API-docs/mail_user_backup_list.html new file mode 100644 index 0000000..9ad9db8 --- /dev/null +++ b/remoting_client/API-docs/mail_user_backup_list.html @@ -0,0 +1,26 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html><head><title>ISCPConfig 3 API Functions</title> + + + + + + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <link rel="stylesheet" type="text/css" href="definitionen.css"> + <style type="text/css"> + </style></head> + +<body> +<div style="padding:40px"> +<h1>mail_user_backup_list(<span class="var">$session_id</span>, <span class="var">$primary_id</span>);</h1> +<br> +<p class="headgrp">Description: </p> +<p class="margin"> Gets list of all available mail backups. If no $primary_id (mail-domain-id) is given, all mail backups available on this server are read.</p> +<br> +<p class="headgrp">Input Variables: </p> +<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id (mail-domain-id)</span></p> +<p class="headgrp">Output: </p> +<p class="margin"> Returns array of all available backups.</p> +</div> + +</body></html> diff --git a/remoting_client/API-docs/navigation.html b/remoting_client/API-docs/navigation.html index 6829df5..917c6ba 100644 --- a/remoting_client/API-docs/navigation.html +++ b/remoting_client/API-docs/navigation.html @@ -169,6 +169,8 @@ <p><a href="mail_user_filter_delete.html" target="content">mail_user_filter_delete</a></p> <p><a href="mail_user_filter_get.html" target="content">mail_user_filter_get</a></p> <p><a href="mail_user_filter_update.html" target="content">mail_user_filter_update</a></p> +<p><a href="mail_user_backup_list.html" target="content">mail_user_backup_list</a></p> +<p><a href="mail_user_backup.html" target="content">mail_user_backup</a></p> <p><a href="mail_whitelist_add.html" target="content">mail_whitelist_add</a></p> <p><a href="mail_whitelist_delete.html" target="content">mail_whitelist_delete</a></p> <p><a href="mail_whitelist_get.html" target="content">mail_whitelist_get</a></p> diff --git a/server/lib/classes/cron.d/500-backup.inc.php b/server/lib/classes/cron.d/500-backup.inc.php index f87e4db..68c5920 100644 --- a/server/lib/classes/cron.d/500-backup.inc.php +++ b/server/lib/classes/cron.d/500-backup.inc.php @@ -51,6 +51,7 @@ global $app, $conf; $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); + $global_config = $app->getconf->get_global_config('sites'); $backup_dir = $server_config['backup_dir']; $backup_mode = $server_config['backup_mode']; if($backup_mode == '') $backup_mode = 'userzip'; @@ -122,14 +123,16 @@ } if($retval == 0 || ($backup_mode != 'userzip' && $retval == 1) || ($backup_mode == 'userzip' && $retval == 12)) { // tar can return 1, zip can return 12(due to harmless warings) and still create valid backups if(is_file($web_backup_dir.'/'.$web_backup_file)){ - chown($web_backup_dir.'/'.$web_backup_file, 'root'); - chgrp($web_backup_dir.'/'.$web_backup_file, 'root'); + $backupusername = ($global_config['backups_include_into_web_quota'] == 'y') ? $web_user : 'root'; + $backupgroup = ($global_config['backups_include_into_web_quota'] == 'y') ? $web_group : 'root'; + chown($web_backup_dir.'/'.$web_backup_file, $backupusername); + chgrp($web_backup_dir.'/'.$web_backup_file, $backupgroup); chmod($web_backup_dir.'/'.$web_backup_file, 0750); //* Insert web backup record in database //$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')"; //$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id'); - $filesize = $app->functions->formatBytes(filesize($web_backup_dir.'/'.$web_backup_file)); + $filesize = filesize($web_backup_dir.'/'.$web_backup_file); $sql = "INSERT INTO web_backup (server_id, parent_domain_id, backup_type, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)"; $app->db->query($sql, $conf['server_id'], $web_id, 'web', $backup_mode, time(), $web_backup_file, $filesize); if($app->db->dbHost != $app->dbmaster->dbHost) @@ -215,8 +218,16 @@ $db_backup_dir = $backup_dir.'/web'.$web_id; if(!is_dir($db_backup_dir)) mkdir($db_backup_dir, 0750); chmod($db_backup_dir, 0750); - chown($db_backup_dir, 'root'); - chgrp($db_backup_dir, 'root'); + $backupusername = 'root'; + $backupgroup = 'root'; + if ($global_config['backups_include_into_web_quota'] == 'y') { + $sql = "SELECT * FROM web_domain WHERE domain_id = ".$rec['parent_domain_id']; + $webdomain = $app->db->queryOneRecord($sql); + $backupusername = $webdomain['system_user']; + $backupgroup = $webdomain['system_group']; + } + chown($db_backup_dir, $backupusername); + chgrp($db_backup_dir, $backupgroup); //* Do the mysql database backup with mysqldump $db_id = $rec['database_id']; @@ -238,7 +249,7 @@ //* Insert web backup record in database //$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')"; //$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id'); - $filesize = $app->functions->formatBytes(filesize($db_backup_dir.'/'.$db_backup_file.'.gz')); + $filesize = filesize($db_backup_dir.'/'.$db_backup_file.'.gz'); $sql = "INSERT INTO web_backup (server_id, parent_domain_id, backup_type, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)"; $app->db->query($sql, $conf['server_id'], $web_id, 'mysql', 'sqlgz', time(), $db_backup_file.'.gz', $filesize); if($app->db->dbHost != $app->dbmaster->dbHost) diff --git a/server/lib/classes/cron.d/500-backup_mail.inc.php b/server/lib/classes/cron.d/500-backup_mail.inc.php index ac937f9..a13974a 100644 --- a/server/lib/classes/cron.d/500-backup_mail.inc.php +++ b/server/lib/classes/cron.d/500-backup_mail.inc.php @@ -51,7 +51,8 @@ $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); - + $global_config = $app->getconf->get_global_config('sites'); + $backup_dir = $server_config['backup_dir']; $backup_dir_permissions =0750; @@ -75,14 +76,38 @@ foreach($records as $rec) { //* Do the mailbox backup if($rec['backup_interval'] == 'daily' or ($rec['backup_interval'] == 'weekly' && date('w') == 0) or ($rec['backup_interval'] == 'monthly' && date('d') == '01')) { + $email = $rec['email']; $temp = explode("@",$email); $domain = $temp[1]; unset($temp);; $domain_rec=$app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = ?", $domain); + + $backupusername = 'root'; + $backupgroup = 'root'; + if ($global_config['backups_include_into_web_quota'] == 'y') { + // this only works, if mail and webdomains are on the same server + // find webdomain fitting to maildomain + $sql = "SELECT * FROM web_domain WHERE domain = '".$domain_rec['domain']."'"; + $webdomain = $app->db->queryOneRecord($sql); + // if this is not also the website, find website now + if ($webdomain && ($webdomain['parent_domain_id'] != 0)) { + do { + $sql = "SELECT * FROM web_domain WHERE domain_id = ".$webdomain['parent_domain_id']; + $webdomain = $app->db->queryOneRecord($sql); + } while ($webdomain && ($webdomain['parent_domain_id'] != 0)); + } + // if webdomain is found, change username/group now + if ($webdomain) { + $backupusername = $webdomain['system_user']; + $backupgroup = $webdomain['system_group']; + } + } $mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id']; if(!is_dir($mail_backup_dir)) mkdir($mail_backup_dir, 0750); chmod($mail_backup_dir, $backup_dir_permissions); + chown($mail_backup_dir, $backupusername); + chgrp($mail_backup_dir, $backupgroup); $mail_backup_file = 'mail'.$rec['mailuser_id'].'_'.date('Y-m-d_H-i'); @@ -97,20 +122,22 @@ //* create archives if($backup_mode == 'userzip') { $mail_backup_file.='.zip'; - exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/nul', $tmp_output, $retval); + exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/null', $tmp_output, $retval); } else { /* Create a tar.gz backup */ $mail_backup_file.='.tar.gz'; exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval); } if($retval == 0){ - chown($mail_backup_dir.'/'.$mail_backup_file, 'root'); - chgrp($mail_backup_dir.'/'.$mail_backup_file, 'root'); + chown($mail_backup_dir.'/'.$mail_backup_file, $backupusername); + chgrp($mail_backup_dir.'/'.$mail_backup_file, $backupgroup); chmod($mail_backup_dir.'/'.$mail_backup_file, 0640); /* Insert mail backup record in database */ + $filesize = filesize($mail_backup_dir.'/'.$mail_backup_file); $sql = "INSERT INTO mail_backup (server_id, parent_domain_id, mailuser_id, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)"; - $app->db->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id'], $backup_mode, time(), $mail_backup_file, $app->functions->formatBytes(filesize($mail_backup_dir.'/'.$mail_backup_file))); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id'], $backup_mode, time(), $mail_backup_file, $app->functions->formatBytes(filesize($mail_backup_dir.'/'.$mail_backup_file))); + $app->db->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id'], $backup_mode, time(), $mail_backup_file, $filesize); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id'], $backup_mode, time(), $mail_backup_file, $filesize); + unset($filesize); } else { /* Backup failed - remove archive */ if(is_file($mail_backup_dir.'/'.$mail_backup_file)) unlink($mail_backup_dir.'/'.$mail_backup_file); diff --git a/server/plugins-available/backup_plugin.inc.php b/server/plugins-available/backup_plugin.inc.php index 863ac98..3c3531c 100644 --- a/server/plugins-available/backup_plugin.inc.php +++ b/server/plugins-available/backup_plugin.inc.php @@ -53,7 +53,9 @@ //* Register for actions $app->plugins->registerAction('backup_download', $this->plugin_name, 'backup_action'); $app->plugins->registerAction('backup_restore', $this->plugin_name, 'backup_action'); - + //$app->plugins->registerAction('backup_download_mail', $this->plugin_name, 'backup_action_mail'); + $app->plugins->registerAction('backup_restore_mail', $this->plugin_name, 'backup_action_mail'); + } //* Do a backup action @@ -62,7 +64,6 @@ $backup_id = intval($data); $backup = $app->dbmaster->queryOneRecord("SELECT * FROM web_backup WHERE backup_id = $backup_id"); - $mail_backup = $app->dbmaster->queryOneRecord("SELECT * FROM mail_backup WHERE backup_id = $backup_id"); if(is_array($backup)) { @@ -158,38 +159,51 @@ } else { $app->log('Backup directory not ready.', LOGLEVEL_DEBUG); } - //* Restore a mail backup - florian@schaal-24.de - } elseif (is_array($mail_backup) && $action_name == 'backup_restore') { - $app->uses('ini_parser,file,getconf'); + } else { + $app->log('No backup with ID '.$backup_id.' found.', LOGLEVEL_DEBUG); + } + return 'ok'; + } + + //* Restore a mail backup - florian@schaal-24.de + public function backup_action_mail($action_name, $data) { + global $app, $conf; + + $backup_id = intval($data); + $mail_backup = $app->dbmaster->queryOneRecord("SELECT * FROM mail_backup WHERE backup_id = $backup_id"); + + if (is_array($mail_backup) && $action_name == 'backup_restore_mail') { + $app->uses('ini_parser,file,getconf'); + $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir']; - $backup_dir_is_ready = true; + //* mount backup directory, if necessary if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $backup_dir_is_ready = false; - + if($backup_dir_is_ready){ $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); $domain_rec = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain_id = ".intval($mail_backup['parent_domain_id'])); - + $backup_dir = $server_config['backup_dir'].'/mail'.$domain_rec['domain_id']; $mail_backup_file = $backup_dir.'/'.$mail_backup['filename']; - + $sql = "SELECT * FROM mail_user WHERE server_id = '".$conf['server_id']."' AND mailuser_id = ".intval($mail_backup['mailuser_id']); $record = $app->db->queryOneRecord($sql); - + //* strip mailbox from maildir $domain_dir=explode('/',$record['maildir']); $_temp=array_pop($domain_dir);unset($_temp); $domain_dir=implode('/',$domain_dir); - + if(!is_dir($domain_dir)) { mkdir($domain_dir, 0700); //* never create the full path chown($domain_dir, $mail_config['mailuser_name']); chgrp($domain_dir, $mail_config['mailuser_group']); } - + if(file_exists($mail_backup_file) && $record['homedir'] != '' && $record['homedir'] != '/' && !stristr($mail_backup_file,'..') && !stristr($mail_backup_file,'etc') && $mail_config['homedir_path'] == $record['homedir'] && is_dir($domain_dir)) { if($mail_backup['backup_mode'] == 'userzip') { copy($mail_backup_file, $domain_dir.'/'.$mail_backup['filename']); @@ -222,7 +236,8 @@ return 'ok'; } - + + } // end class ?> -- Gitblit v1.9.1