Skip to content

Commit 5f0a37f

Browse files
committed
added backup-functions to Remote-API (FS#2832)
1 parent 5cc962c commit 5f0a37f

File tree

5 files changed

+114
-1
lines changed

5 files changed

+114
-1
lines changed

interface/lib/classes/remote.d/sites.inc.php

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,65 @@ public function sites_database_get_all_by_user($session_id, $client_id)
893893
$all = $app->db->queryAllRecords($sql);
894894
return $all;
895895
}
896-
896+
897+
//** backup functions -----------------------------------------------------------------------------------
898+
public function sites_web_domain_backup_list($session_id, $site_id = null)
899+
{
900+
global $app;
901+
902+
if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) {
903+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
904+
return false;
905+
}
906+
907+
$result = $app->db->queryAllRecords("SELECT * FROM web_backup".(($site_id != null)?' WHERE parent_domain_id = ?':''), $app->functions->intval($site_id));
908+
return $result;
909+
}
910+
911+
//* Backup download and restoration by Abdi Joseph
912+
public function sites_web_domain_backup($session_id, $primary_id, $action_type)
913+
{
914+
global $app;
915+
916+
if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) {
917+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
918+
return false;
919+
}
920+
921+
//*Set variables
922+
$backup_record = $app->db->queryOneRecord("SELECT * FROM `web_backup` WHERE `backup_id`= ?", $primary_id);
923+
$server_id = $backup_record['server_id'];
924+
925+
//*Set default action state
926+
$action_state = "pending";
927+
$tstamp = time();
928+
929+
//* Basic validation of variables
930+
if ($server_id <= 0) {
931+
$this->server->fault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
932+
return false;
933+
}
934+
935+
if ($action_type != 'backup_download' and $action_type != 'backup_restore') {
936+
$this->server->fault('invalid_action', "Invalid action_type $action_type");
937+
return false;
938+
}
939+
940+
//* Validate instance
941+
$instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`= ? and `action_type`= ? and `action_state`= ?", $primary_id, $action_type, 'pending');
942+
if ($instance_record['action_id'] >= 1) {
943+
$this->server->fault('duplicate_action', "There is already a pending $action_type action");
944+
return false;
945+
}
946+
947+
//* Save the record
948+
if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) {
949+
return true;
950+
} else {
951+
return false;
952+
}
953+
}
954+
897955
//** quota functions -----------------------------------------------------------------------------------
898956
public function quota_get_by_user($session_id, $client_id)
899957
{

interface/web/sites/lib/remote.conf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
$function_list['sites_ftp_user_get,sites_ftp_user_server_get,sites_ftp_user_add,sites_ftp_user_update,sites_ftp_user_delete'] = 'Sites FTP-User functions';
66
$function_list['sites_shell_user_get,sites_shell_user_add,sites_shell_user_update,sites_shell_user_delete'] = 'Sites Shell-User functions';
77
$function_list['sites_web_domain_get,sites_web_domain_add,sites_web_domain_update,sites_web_domain_delete,sites_web_domain_set_status'] = 'Sites Domain functions';
8+
$function_list['sites_web_domain_backup'] = 'Sites Backup functions';
89
$function_list['sites_web_aliasdomain_get,sites_web_aliasdomain_add,sites_web_aliasdomain_update,sites_web_aliasdomain_delete'] = 'Sites Aliasdomain functions';
910
$function_list['sites_web_subdomain_get,sites_web_subdomain_add,sites_web_subdomain_update,sites_web_subdomain_delete'] = 'Sites Subdomain functions';
1011

remoting_client/API-docs/navigation.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ <h3>S</h3>
226226
<p><a href="sites_web_domain_get.html" target="content">sites_web_domain_get</a></p>
227227
<p><a href="sites_web_domain_set_status.html" target="content">sites_web_domain_set_status</a></p>
228228
<p><a href="sites_web_domain_update.html" target="content">sites_web_domain_update</a></p>
229+
p><a href="sites_web_domain_backup_list.html" target="content">sites_web_domain_backup_list</a></p>
230+
<p><a href="sites_web_domain_backup.html" target="content">sites_web_domain_backup</a></p>
229231
<p><a href="sites_web_subdomain_add.html" target="content">sites_web_subdomain_add</a></p>
230232
<p><a href="sites_web_subdomain_delete.html" target="content">sites_web_subdomain_delete</a></p>
231233
<p><a href="sites_web_subdomain_get.html" target="content">sites_web_subdomain_get</a></p>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2+
<html><head><title>ISCPConfig 3 API Functions</title>
3+
4+
5+
6+
7+
8+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9+
<link rel="stylesheet" type="text/css" href="definitionen.css">
10+
<style type="text/css">
11+
</style></head>
12+
13+
<body>
14+
<div style="padding:40px">
15+
<h1>sites_web_domain_backup(<span class="var">$session_id</span>, <span class="var">$primary_id</span>, <span class="var">$action_type</span>);</h1>
16+
<br>
17+
<p class="headgrp">Description: </p>
18+
<p class="margin"> Adds a new backup / restore task. Please note: <em>$action_type</em> is either <em>backup_download</em> or <em>backup_restore</em></p>
19+
<br>
20+
<p class="headgrp">Input Variables: </p>
21+
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span>, <span class="var">$action_type</span></p>
22+
<p class="headgrp">Output: </p>
23+
<p class="margin"> Returns <em>TRUE</em> if successfull or <em>FALSE</em> if failure.</p>
24+
</div>
25+
26+
</body></html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2+
<html><head><title>ISCPConfig 3 API Functions</title>
3+
4+
5+
6+
7+
8+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9+
<link rel="stylesheet" type="text/css" href="definitionen.css">
10+
<style type="text/css">
11+
</style></head>
12+
13+
<body>
14+
<div style="padding:40px">
15+
<h1>sites_web_domain_backup_list(<span class="var">$session_id</span>, <span class="var">$site_id</span>);</h1>
16+
<br>
17+
<p class="headgrp">Description: </p>
18+
<p class="margin"> Gets list of all available backups. If no $site_id given, all backups available on this server are read.</p>
19+
<br>
20+
<p class="headgrp">Input Variables: </p>
21+
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$site_id</span></p>
22+
<p class="headgrp">Output: </p>
23+
<p class="margin"> Returns array of all available backups.</p>
24+
</div>
25+
26+
</body></html>

0 commit comments

Comments
 (0)