From 22391cf8091ccaa1a2f9fe08ebe64647d5459a4c Mon Sep 17 00:00:00 2001 From: "Ramón M. Gómez" Date: Thu, 9 Jan 2020 13:50:09 +0100 Subject: #949: Add session info to the computer properties form. --- .../idiomas/php/cat/configuraciones_cat.php | 10 +- .../idiomas/php/eng/configuraciones_eng.php | 8 ++ .../idiomas/php/esp/configuraciones_esp.php | 10 +- admin/WebConsole/principal/configuraciones.php | 115 +++++++++++++++++++-- 4 files changed, 128 insertions(+), 15 deletions(-) (limited to 'admin/WebConsole') diff --git a/admin/WebConsole/idiomas/php/cat/configuraciones_cat.php b/admin/WebConsole/idiomas/php/cat/configuraciones_cat.php index 6eaf723a..9c9cb33f 100644 --- a/admin/WebConsole/idiomas/php/cat/configuraciones_cat.php +++ b/admin/WebConsole/idiomas/php/cat/configuraciones_cat.php @@ -1,8 +1,8 @@ - -Administración web de aulas - - - - - + + + Administración web de aulas + + + + - - + + + +/** + * @param object $cmd + * @param int $idordenador + */ +function datos_sesiones($cmd, $idordenador) +{ + global $TbMsg; + $os_color = ['Windows' => "blue", 'Linux' => "magenta", 'MacOS' => "orange"]; + $html = ""; + $ip = ""; + + $cmd->texto = "SELECT ip FROM ordenadores WHERE idordenador = $idordenador"; + $rs = new Recordset; + $rs->Comando=&$cmd; + if ($rs->Abrir()){ + $rs->Primero(); + $ip = $rs->campos["ip"]; + $rs->Cerrar(); + } + if ($ip) { + foreach (file(LOG_FILE) as $line) { + if (strstr($line, "ip=$ip")) { + $fields = preg_split("/[:,=]/", rtrim($line, ". \t\n\r\0\x0B")); + $date_time = str_replace("T", " ", $fields[0]) . ":" . $fields[1] . ":" . + preg_replace("/\+.*$/", "", $fields[2]); + $operation = trim($fields[3]); + $username = $os_type = $os_version = ""; + switch ($operation) { + case "OGAgent started": + $operation = "Iniciar"; + $os_type = $fields[14] ?? ""; + $os_version = trim($fields[15] ?? ""); + break; + case "OGAgent stopped": + $operation = "Apagar"; + $os_type = $fields[14] ?? ""; + $os_version = trim($fields[15] ?? ""); + break; + case "User logged in": + $operation = "Entrar"; + $username = $fields[7] ?? ""; + $os_type = $fields[11] ?? ""; + $os_version = trim($fields[12] ?? ""); + break; + case "User logged out": + $operation = "Salir"; + $username = $fields[7] ?? "-"; + break; + default: + $operation = "ERROR"; + } + $color = $os_color[$os_type] ?? ""; + $html .= << + $date_time + $operation + $os_version + $username + +EOT; + } + } + if (!empty($html)) { + echo << + + ${TbMsg["SECT_SESSIONS"]} + + + ${TbMsg["SESS_DATETIME"]} + ${TbMsg["SESS_OPERATION"]} + ${TbMsg["SESS_OPSYS"]} + ${TbMsg["SESS_USER"]} + +$html + +EOT; + } else { + echo << + + ${TbMsg["SESS_NOSESSIONS"]} + + +EOT; + } + } +} -- cgit v1.2.3-18-g5258