summaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2020-07-23 18:27:24 +0200
committerRamón M. Gómez <ramongomez@us.es>2020-07-23 18:27:24 +0200
commitc607df7196c186ef3fc721901bdaf01b5638be98 (patch)
treef9faecab85ba15224e3c001fe361cd78e76c1ab7 /admin
parent363defe753c42058849721b304c75757cab34591 (diff)
#992: Set/unset URL to release a client for remote access.
Diffstat (limited to 'admin')
-rw-r--r--admin/Database/ogAdmBD-1.1.1c-1.2.0.sql14
-rw-r--r--admin/Database/ogAdmBD.sql5
-rw-r--r--admin/WebConsole/rest/remotepc.php22
3 files changed, 29 insertions, 12 deletions
diff --git a/admin/Database/ogAdmBD-1.1.1c-1.2.0.sql b/admin/Database/ogAdmBD-1.1.1c-1.2.0.sql
index e02aad1e..fb16fe46 100644
--- a/admin/Database/ogAdmBD-1.1.1c-1.2.0.sql
+++ b/admin/Database/ogAdmBD-1.1.1c-1.2.0.sql
@@ -22,15 +22,25 @@ CREATE PROCEDURE altercols() BEGIN
ADD inremotepc SMALLINT NOT NULL DEFAULT 0,
ADD maintenance SMALLINT NOT NULL DEFAULT 0;
END IF;
+ # Añadir campo con URL para liberar equipo reservado para acceso remoto (ticket #992).
+ IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS
+ WHERE COLUMN_NAME='urlrelease' AND TABLE_NAME='remotepc' AND TABLE_SCHEMA=DATABASE())
+ THEN
+ ALTER TABLE remotepc
+ ADD urlrelease VARCHAR(100) DEFAULT NULL;
+ END IF;
END//
# Ejecutar actualización condicional.
DELIMITER ';'
CALL altercols();
DROP PROCEDURE altercols;
-# Redefinir algunos campos como no nulos.
+# Redefinir campos como no nulos.
ALTER TABLE aulas
MODIFY inremotepc SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE imagenes
MODIFY inremotepc SMALLINT NOT NULL DEFAULT 0;
-
+# Redefinir campos como nulos por defecto.
+ALTER TABLE remotepc
+ MODIFY urllogin VARCHAR(100) DEFAULT NULL,
+ MODIFY urllogout VARCHAR(100) DEFAULT NULL;
diff --git a/admin/Database/ogAdmBD.sql b/admin/Database/ogAdmBD.sql
index 4bac0af0..cc5d001b 100644
--- a/admin/Database/ogAdmBD.sql
+++ b/admin/Database/ogAdmBD.sql
@@ -794,8 +794,9 @@ DROP TABLE IF EXISTS `remotepc`;
CREATE TABLE `remotepc` (
`id` int(11) NOT NULL DEFAULT 0,
`reserved` datetime DEFAULT NULL,
- `urllogin` varchar(100),
- `urllogout` varchar(100),
+ `urllogin` varchar(100) DEFAULT NULL,
+ `urllogout` varchar(100) DEFAULT NULL,
+ `urlrelease` varchar(100) DEFAULT NULL,
`language` varchar(5),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/admin/WebConsole/rest/remotepc.php b/admin/WebConsole/rest/remotepc.php
index 3b4f627c..4b8270aa 100644
--- a/admin/WebConsole/rest/remotepc.php
+++ b/admin/WebConsole/rest/remotepc.php
@@ -157,10 +157,12 @@ EOD;
$timestamp = time();
$cmd->texto = <<<EOD
INSERT INTO remotepc
- SET id='$clntid', reserved=NOW() + INTERVAL $maxtime HOUR, urllogin=NULL, urllogout=NULL
+ SET id = '$clntid', reserved = NOW() + INTERVAL $maxtime HOUR,
+ urllogin = NULL, urllogout = NULL, urlrelease = NULL
ON DUPLICATE KEY UPDATE
- id=VALUES(id), reserved=VALUES(reserved),
- urllogin=VALUES(urllogin), urllogout=VALUES(urllogout);
+ id = VALUES(id), reserved = VALUES(reserved),
+ urllogin = VALUES(urllogin), urllogout = VALUES(urllogout),
+ urlrelease = VALUES(urlrelease);
EOD;
$t1 = $cmd->Ejecutar();
$cmd->texto = <<<EOD
@@ -197,7 +199,8 @@ CREATE EVENT e_timeout_$clntid
AND (SELECT @action_id := idaccion);
IF @action_id IS NOT NULL THEN
UPDATE remotepc
- SET reserved=NOW() - INTERVAL 1 SECOND, urllogin=NULL, urllogout=NULL
+ SET reserved = NOW() - INTERVAL 1 SECOND,
+ urllogin = NULL, urllogout = NULL, urlrelease = NULL
WHERE id = '$clntid';
DELETE FROM acciones
WHERE idaccion = @action_id;
@@ -250,6 +253,7 @@ EOD;
* @note Route: /ous/:ouid/labs/:labid/clients/:clntid/events, Method: POST
* @param string urlLogin URL to redirect login notification.
* @param string urlLogout URL to redirect logout notification.
+ * @param string urlRelease URL to release a session
* @warning Events parameters will be stored in a new "remotepc" table.
*/
$app->post('/ous/:ouid/labs/:labid/clients/:clntid/events', 'validateApiKey',
@@ -272,6 +276,7 @@ $app->post('/ous/:ouid/labs/:labid/clients/:clntid/events', 'validateApiKey',
$input = json_decode($app->request()->getBody());
$urlLogin = htmlspecialchars($input->urlLogin);
$urlLogout = htmlspecialchars($input->urlLogout);
+ $urlRelease = htmlspecialchars($input->urlRelease ?? "");
if (filter_var($urlLogin, FILTER_VALIDATE_URL) === false) {
throw new Exception("Must be a valid URL for login notification");
}
@@ -312,9 +317,10 @@ EOD;
// Updating DB if client is reserved.
$cmd->CreaParametro("@urllogin", $urlLogin, 0);
$cmd->CreaParametro("@urllogout", $urlLogout, 0);
+ $cmd->CreaParametro("@urlrelease", $urlRelease, 0);
$cmd->texto = <<<EOD
UPDATE remotepc
- SET urllogin=@urllogin, urllogout=@urllogout
+ SET urllogin = @urllogin, urllogout = @urllogout, urlrelease = NULLIF(@urlrelease, '')
WHERE id='$clntid';
EOD;
if ($cmd->Ejecutar()) {
@@ -509,8 +515,9 @@ EOD;
$cmd->Ejecutar();
$cmd->texto = <<<EOD
UPDATE remotepc
- SET reserved=NOW() - INTERVAL 1 SECOND, urllogin=NULL, urllogout=NULL
- WHERE id='$clntid';
+ SET reserved = NOW() - INTERVAL 1 SECOND,
+ urllogin = NULL, urllogout = NULL, urlrelease = NULL
+ WHERE id = '$clntid';
EOD;
$cmd->Ejecutar();
$cmd->texto = <<<EOD
@@ -554,4 +561,3 @@ EOD;
}
);
-