summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2019-05-30 15:28:20 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2019-05-30 17:17:39 +0200
commitdc827546044e8df83adc0bb10536c2f85d6039f3 (patch)
treec0881e696b7765f28aa5c223e5393d62178a951a /admin/WebConsole
parentda462c863441073ca429811bd1d023e929d611db (diff)
#915 adapt web console to use new stop command in REST API
SocketHidra "purgar" has been replaced by POST /stop.
Diffstat (limited to 'admin/WebConsole')
-rw-r--r--admin/WebConsole/includes/restfunctions.php12
-rw-r--r--admin/WebConsole/principal/purgar.php21
2 files changed, 13 insertions, 20 deletions
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php
index ea0fec85..cb8e0f08 100644
--- a/admin/WebConsole/includes/restfunctions.php
+++ b/admin/WebConsole/includes/restfunctions.php
@@ -13,6 +13,7 @@ define('OG_REST_CMD_RUN', 'shell/run');
define('OG_REST_CMD_OUTPUT', 'shell/output');
define('OG_REST_CMD_POWEROFF', 'poweroff');
define('OG_REST_CMD_REBOOT', 'reboot');
+define('OG_REST_CMD_STOP', 'stop');
define('OG_REST_PARAM_CLIENTS', 'clients');
define('OG_REST_PARAM_ADDR', 'addr');
@@ -45,7 +46,7 @@ function common_request($command, $type, $data = null, $custom = 'GET') {
if ($curl_response === false || $info['http_code'] != 200) {
syslog(LOG_ERR, 'error occured during curl exec. Additioanl info: ' . var_export($info));
- return null;
+ return 0;
}
curl_close($curl);
@@ -155,6 +156,15 @@ function reboot($string_ips) {
common_request(OG_REST_CMD_REBOOT, POST, $data);
}
+function stop($string_ips) {
+
+ $ips = explode(';',$string_ips);
+
+ $data = array(OG_REST_PARAM_CLIENTS => $ips);
+
+ common_request(OG_REST_CMD_STOP, POST, $data);
+}
+
/*
* @function multiRequest.
* @param URLs array (may include header and POST data), cURL options array.
diff --git a/admin/WebConsole/principal/purgar.php b/admin/WebConsole/principal/purgar.php
index bc945ffd..aef8aebe 100644
--- a/admin/WebConsole/principal/purgar.php
+++ b/admin/WebConsole/principal/purgar.php
@@ -15,6 +15,7 @@
include_once("../includes/comunes.php");
include_once("../includes/CreaComando.php");
include_once("../includes/RecopilaIpesMacs.php");
+ include_once('../includes/restfunctions.php');
//________________________________________________________________________________________________________
$ambito=0;
$idambito=0;
@@ -41,23 +42,5 @@
//________________________________________________________________________________________________________
// Envio al servidor de la petición
//________________________________________________________________________________________________________
- $trama="";
- $shidra=new SockHidra($servidorhidra,$hidraport);
- if ($shidra->conectar()){ // Se ha establecido la conexión con el servidor hidra
- $parametros="nfn=".$funcion.chr(13);
- $parametros.=$aplicacion;
- $parametros.=$atributos;
- $parametros.=$acciones;
- $shidra->envia_comando($parametros);
- $trama=$shidra->recibe_respuesta();
- $shidra->desconectar();
- $hlonprm=hexdec(substr($trama,$LONCABECERA,$LONHEXPRM));
- $parametros=substr($trama,$LONCABECERA+$LONHEXPRM,$hlonprm);
- $ValorParametros=extrae_parametros($parametros,chr(13),'=');
- $trama_notificacion=$ValorParametros["res"];
- echo $trama_notificacion; // Devuelve respuesta
- }
- else
- echo "0"; // Error de conexión
-
+ echo stop($cadenaip) === 0 ? "0" : "1";