summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2019-10-23 16:43:13 +0200
committerRamón M. Gómez <ramongomez@us.es>2019-10-23 16:43:13 +0200
commitdbb1b6ccc43771e85661cf8520ae6e3e9c42e5b7 (patch)
tree5b3a5903302e205491bfb20311884f05c6d48a21
parenta0a2149b8e6c19f5f86bd4f72b375a3696a9e9fd (diff)
#915: REST function to get client status uses new ogAdmServer REST API.
-rw-r--r--admin/WebConsole/rest/server.php34
1 files changed, 6 insertions, 28 deletions
diff --git a/admin/WebConsole/rest/server.php b/admin/WebConsole/rest/server.php
index 6fb3dad7..cd786ac7 100644
--- a/admin/WebConsole/rest/server.php
+++ b/admin/WebConsole/rest/server.php
@@ -90,9 +90,8 @@ function getStatus($ouid, $labid, $clntid=0) {
// Database query.
$cmd->texto = <<<EOD
-SELECT adm.idusuario, entornos.ipserveradm, entornos.portserveradm,
- aulas.idaula, ordenadores.idordenador, ordenadores.ip
- FROM entornos, ordenadores
+SELECT adm.idusuario, aulas.idaula, ordenadores.idordenador, ordenadores.ip
+ FROM ordenadores
JOIN aulas USING(idaula)
RIGHT JOIN administradores_centros AS adm USING(idcentro)
WHERE adm.idusuario = '$userid'
@@ -112,41 +111,20 @@ EOD;
$rs->Primero();
// Check if user is an UO admin and asset exists.
if (checkAdmin($rs->campos["idusuario"]) and (($single and checkParameter($rs->campos["idordenador"])) or (! $single and checkParameter($rs->campos["idaula"])))) {
- // First, try to connect to ogAdmCleint service.
- $serverip = $rs->campos["ipserveradm"];
- $serverport = $rs->campos["portserveradm"];
while (!$rs->EOF) {
$id[$rs->campos["ip"]] = $rs->campos["idordenador"];
$stat[$rs->campos["ip"]] = $status['OFF'];
$rs->Siguiente();
}
- // Connect to reset client's status.
+ // Get client status.
$clientid = implode(",", $id);
$clientip = implode(";", array_keys($id));
- $reqframe = "nfn=Sondeo\r".
- "ido=$clientid\r".
- "iph=$clientip\r";
- $result = sendCommand($serverip, $serverport, $reqframe, $values);
- // Connect to fetch client's status.
- // Asuming client is off by default.
- $values["tso"]="OFF";
- // Iterate to check client's status.
- // Exit if status!=OFF or end iterations (status=OFF).
- $maxIter = 30;
- for ($i=1; $i<$maxIter and preg_match('/OFF/', $values["tso"]); $i++) {
- // Connect to check status.
- $reqframe = "nfn=respuestaSondeo\r".
- "ido=$clientid\r".
- "iph=$clientip\r";
- $result = sendCommand($serverip, $serverport, $reqframe, $values);
- // Wait until next checking (0.1 ms).
- usleep(100000);
- }
+ $result = clients(2, $clientip);
// Parse status response.
if ($result) {
// Check status type.
- if (checkParameter($values["tso"])) {
- foreach (explode(";", $values["tso"]) as $data) {
+ if (checkParameter($result)) {
+ foreach (explode(";", $result) as $data) {
if (!empty($data)) {
list($clip, $clst) = explode("/", $data);
if ($clst != "OFF") {