diff --git a/interface/lib/classes/remote.d/server.inc.php b/interface/lib/classes/remote.d/server.inc.php index 7b56228b9c150c9daca80441855b5be7ad6c62fa..738b6671b3e488e4c82519427fa2bb28fcb29a54 100644 --- a/interface/lib/classes/remote.d/server.inc.php +++ b/interface/lib/classes/remote.d/server.inc.php @@ -142,6 +142,34 @@ class remoting_server extends remoting { } } + /** + Set a value in the server configuration + @param int session id + @param int server id + @param string section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc + @param string key of the option that you want to set + @param string option value that you want to set + */ + + + public function server_config_set($session_id, $server_id, $section, $key, $value) { + global $app; + if(!$this->checkPerm($session_id, 'server_config_set')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if (!empty($server_id) && $server_id > 0 && $section != '' && $key != '') { + $app->uses('remoting_lib,getconf,ini_parser'); + $server_config_array = $app->getconf->get_server_config($server_id); + $server_config_array[$section][$key] = $value; + $server_config_str = $app->ini_parser->get_ini_string($server_config_array); + $app->db->datalogUpdate('server', array("config" => $server_config_str), 'server_id', $server_id); + } else { + throw new SoapFault('invalid_function_parameter', 'Invalid function parameter.'); + return false; + } + } + /** Gets a list of all servers @param int session_id diff --git a/interface/web/admin/lib/remote.conf.php b/interface/web/admin/lib/remote.conf.php index 37aec717946d5dc66ffbdda4b76cbfbff95a3d9a..bb9bba0d6c720282a6fb77600afdf754ed688c32 100644 --- a/interface/web/admin/lib/remote.conf.php +++ b/interface/web/admin/lib/remote.conf.php @@ -1,6 +1,6 @@ diff --git a/remoting_client/examples/server_config_set.php b/remoting_client/examples/server_config_set.php new file mode 100644 index 0000000000000000000000000000000000000000..c2e9ac13580e25e3f25c77444cce3e46a78a2971 --- /dev/null +++ b/remoting_client/examples/server_config_set.php @@ -0,0 +1,45 @@ + [ + // set some SSL/TLS specific options + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true + ] +]); + + +$client = new SoapClient(null, array('location' => $soap_location, + 'uri' => $soap_uri, + 'trace' => 1, + 'exceptions' => 1, + 'stream_context' => $context)); + + +try { + if($session_id = $client->login($username, $password)) { + echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + + //* Set the function parameters. + $server_id = 1; + + $result = $client->server_config_set($session_id, $server_id, 'server', 'migration_mode', 'y'); + + print_r($result); + echo "
"; + + if($client->logout($session_id)) { + echo 'Logged out.
'; + } + + +} catch (SoapFault $e) { + echo $client->__getLastResponse(); + die('SOAP Error: '.$e->getMessage()); +} + +?>