diff options
author | ramon <ramongomez@us.es> | 2016-07-06 10:13:57 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2016-07-06 10:13:57 +0000 |
commit | 31970a07b497ac89f6b8871772f470e152f13bd8 (patch) | |
tree | 375dbb790d3e3344f3437b3fa2401ba3a8ee84c4 /admin | |
parent | 8ec4abc0574a7e45880cb61a4b7c0b2b205b214c (diff) |
#718: Registrar versión de SO en operaciones de inicio y parada de OGAgent en vez de en las de inicio y fin de sesión de usuario.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4981 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin')
-rw-r--r-- | admin/WebConsole/rest/ogagent.php | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/admin/WebConsole/rest/ogagent.php b/admin/WebConsole/rest/ogagent.php index e7874e5b..dc3f4dba 100644 --- a/admin/WebConsole/rest/ogagent.php +++ b/admin/WebConsole/rest/ogagent.php @@ -12,11 +12,14 @@ define('LOG_FILE', '/opt/opengnsys/log/ogagent.log'); // OGAgent notifies that its service is started on client. $app->post('/ogagent/started', function() use ($app) { + $osType = $osVersion = ""; try { // Reading POST parameters in JSON format. $input = json_decode($app->request()->getBody()); $ip = htmlspecialchars($input->ip); $mac = htmlspecialchars($input->mac); + if (isset($input->ostype)) $osType = htmlspecialchars($input->ostype); + if (isset($input->osversion)) $osVersion = str_replace(",", ";", htmlspecialchars($input->osversion)); // Client secret key for secure communications. if (isset($input->secret)) { $secret = htmlspecialchars($input->secret); @@ -24,11 +27,11 @@ $app->post('/ogagent/started', //... } else { // Insecure agent exception. - throw new Exception("Insecure OGAgent started: ip=$ip, mac=$mac"); + throw new Exception("Insecure OGAgent started: ip=$ip, mac=$mac, os=$osType:$osVersion."); } // May check that client is included in the server database? // Default processing: log activity. - file_put_contents(LOG_FILE, date(DATE_RSS).": OGAgent started: ip=$ip, mac=$mac.\n", FILE_APPEND); + file_put_contents(LOG_FILE, date(DATE_RSS).": OGAgent started: ip=$ip, mac=$mac, os=$osType:$osVersion.\n", FILE_APPEND); // Response. $response = ""; jsonResponse(200, $response); @@ -44,14 +47,17 @@ $app->post('/ogagent/started', // OGAgent notifies that its service is stopped on client. $app->post('/ogagent/stopped', function() use ($app) { + $osType = $osVersion = ""; try { // Reading POST parameters in JSON format. $input = json_decode($app->request()->getBody()); $ip = htmlspecialchars($input->ip); $mac = htmlspecialchars($input->mac); + if (isset($input->ostype)) $osType = htmlspecialchars($input->ostype); + if (isset($input->osversion)) $osVersion = str_replace(",", ";", htmlspecialchars($input->osversion)); // May check that client is included in the server database? // Default processing: log activity. - file_put_contents(LOG_FILE, date(DATE_RSS).": OGAgent stopped: ip=$ip, mac=$mac.\n", FILE_APPEND); + file_put_contents(LOG_FILE, date(DATE_RSS).": OGAgent stopped: ip=$ip, mac=$mac, os=$osType:$osVersion.\n", FILE_APPEND); // Response. $response = ""; jsonResponse(200, $response); @@ -67,18 +73,14 @@ $app->post('/ogagent/stopped', // OGAgent notifies that an user logs in. $app->post('/ogagent/loggedin', function() use ($app) { - $osType = $osVersion = ""; try { // Reading POST parameters in JSON format. $input = json_decode($app->request()->getBody()); $ip = htmlspecialchars($input->ip); $user = htmlspecialchars($input->user); - if (isset($input->ostype)) $osType = htmlspecialchars($input->ostype); - //if (isset($input->osversion)) $osVersion = htmlspecialchars(implode(",", $input->osversion)); - if (isset($input->osversion)) $osVersion = str_replace(",", ";", htmlspecialchars($input->osversion)); // May check that client is included in the server database? // Default processing: log activity. - file_put_contents(LOG_FILE, date(DATE_RSS).": User logged in: ip=$ip, user=$user, os=$osType:$osVersion.\n", FILE_APPEND); + file_put_contents(LOG_FILE, date(DATE_RSS).": User logged out: ip=$ip, user=$user.\n", FILE_APPEND); // Response. $response = ""; jsonResponse(200, $response); @@ -94,17 +96,14 @@ $app->post('/ogagent/loggedin', // OGAgent notifies that an user logs out. $app->post('/ogagent/loggedout', function() use ($app) { - $osType = $osVersion = ""; try { // Reading POST parameters in JSON format. $input = json_decode($app->request()->getBody()); $ip = htmlspecialchars($input->ip); $user = htmlspecialchars($input->user); - if (isset($input->ostype)) $osType = htmlspecialchars($input->ostype); - if (isset($input->osversion)) $osVersion = str_replace(",", ";", htmlspecialchars($input->osversion)); // May check that client is included in the server database? // Default processing: log activity. - file_put_contents(LOG_FILE, date(DATE_RSS).": User logged out: ip=$ip, user=$user, os=$osType:$osVersion.\n", FILE_APPEND); + file_put_contents(LOG_FILE, date(DATE_RSS).": User logged out: ip=$ip, user=$user.\n", FILE_APPEND); // Response. $response = ""; jsonResponse(200, $response); |