Skip to content

Commit f14c929

Browse files
author
Till Brehm
committed
Added remote api function 'system_config_set'.
1 parent 91d1615 commit f14c929

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,34 @@ public function update_record_permissions($tablename, $index_field, $index_value
103103
return $app->db->datalogUpdate( $tablename, $permissions, $index_field, $index_value ) ;
104104
}
105105

106+
/**
107+
Set a value in the system configuration
108+
@param int session id
109+
@param int server id
110+
@param string section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
111+
@param string key of the option that you want to set
112+
@param string option value that you want to set
113+
*/
114+
115+
116+
public function system_config_set($session_id, $section, $key, $value) {
117+
global $app;
118+
if(!$this->checkPerm($session_id, 'system_config_set')) {
119+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
120+
return false;
121+
}
122+
if ($section != '' && $key != '') {
123+
$app->uses('remoting_lib,getconf,ini_parser');
124+
$system_config_array = $app->getconf->get_global_config();
125+
$system_config_array[$section][$key] = $value;
126+
$system_config_str = $app->ini_parser->get_ini_string($system_config_array);
127+
$app->db->datalogUpdate('sys_ini', array("config" => $system_config_str), 'sysini_id', 1);
128+
} else {
129+
throw new SoapFault('invalid_function_parameter', 'Invalid function parameter.');
130+
return false;
131+
}
132+
}
133+
106134

107135
}
108136

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$function_list['server_get,server_config_set,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_get,server_ip_add,server_ip_update,server_ip_delete'] = 'Server functions';
3+
$function_list['server_get,server_config_set,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_get,server_ip_add,server_ip_update,server_ip_delete,system_config_set'] = 'Server functions';
44
$function_list['admin_record_permissions'] = 'Record permission changes';
55

66
?>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
require 'soap_config.php';
4+
5+
$context = stream_context_create([
6+
'ssl' => [
7+
// set some SSL/TLS specific options
8+
'verify_peer' => false,
9+
'verify_peer_name' => false,
10+
'allow_self_signed' => true
11+
]
12+
]);
13+
14+
15+
$client = new SoapClient(null, array('location' => $soap_location,
16+
'uri' => $soap_uri,
17+
'trace' => 1,
18+
'exceptions' => 1,
19+
'stream_context' => $context));
20+
21+
22+
try {
23+
if($session_id = $client->login($username, $password)) {
24+
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
25+
}
26+
27+
//* Set the function parameters.
28+
$server_id = 1;
29+
30+
$result = $client->system_config_set($session_id, 'misc', 'company_name', 'ISPConfig');
31+
32+
print_r($result);
33+
echo "<br>";
34+
35+
if($client->logout($session_id)) {
36+
echo 'Logged out.<br />';
37+
}
38+
39+
40+
} catch (SoapFault $e) {
41+
echo $client->__getLastResponse();
42+
die('SOAP Error: '.$e->getMessage());
43+
}
44+
45+
?>

0 commit comments

Comments
 (0)