interface/lib/classes/remote.d/mail.inc.php | ●●●●● patch | view | raw | blame | history | |
interface/web/mail/lib/remote.conf.php | ●●●●● patch | view | raw | blame | history | |
remoting_client/API-docs/mail_user_backup.html | ●●●●● patch | view | raw | blame | history | |
remoting_client/API-docs/mail_user_backup_list.html | ●●●●● patch | view | raw | blame | history | |
remoting_client/API-docs/navigation.html | ●●●●● patch | view | raw | blame | history | |
server/lib/classes/cron.d/500-backup_mail.inc.php | ●●●●● patch | view | raw | blame | history |
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) 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'; remoting_client/API-docs/mail_user_backup.html
New file @@ -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> remoting_client/API-docs/mail_user_backup_list.html
New file @@ -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> 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> server/lib/classes/cron.d/500-backup_mail.inc.php
@@ -81,9 +81,32 @@ 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'); @@ -98,33 +121,13 @@ //* 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){ $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 = ".$domain_rec['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']; } } chown($mail_backup_dir.'/'.$mail_backup_file, $backupusername); chgrp($mail_backup_dir.'/'.$mail_backup_file, $backupgroup); chmod($mail_backup_dir.'/'.$mail_backup_file, 0640);