source: admin/WebConsole/rest/server.php @ fa2b1244

Last change on this file since fa2b1244 was fa2b1244, checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago

#1005 Add support for computer groups in RemotePC

When OpenGnsys is used via RemotePC, a failure occurs when
classrooms with groups of computers are included because the
processing and recursion is not controlled correctly because attempts
are made to add objects to a null array.

This commit adds and populates an array with the computers in the group.

Reviewed-by: Javier Sánchez Parra <jsanchez@…>

  • Property mode set to 100644
File size: 31.7 KB
RevLine 
[fb2ee20]1<?php
2/**
3 * @file    index.php
[3551804]4 * @brief   OpenGnsys Server REST API manager.
[fb2ee20]5 * @warning All input and output messages are formatted in JSON.
6 * @note    Some ideas are based on article "How to create REST API for Android app using PHP, Slim and MySQL" by Ravi Tamada, thanx.
7 * @license GNU GPLv3+
8 * @author  Ramón M. Gómez, ETSII Univ. Sevilla
[3551804]9 * @version 1.1.0 - First version
[ac8b234e]10 * @date    2016-09-19
[fb2ee20]11 */
12
13
14// Auxiliar functions.
15
16/**
17 * @brief    Check if user is administrator and print error messages if not.
[43f3bde]18 * @param    int adminid  Administrator id.
19 * @return   boolean      "true" if admin id. is equals to global user id., otherwise "false".
[fb2ee20]20 */
21function checkAdmin($adminid) {
22        global $userid;
23
24        if ($adminid == $userid) {
25                return true;
26        } else {
27                // Print error message.
28                $response['message'] = 'Cannot access this resource';
29                jsonResponse(401, $response);
30                return false;
31        }
32}
33
[606a0c7]34/**
35 * @fn    addClassroomGroup(&$classroomGroups, $rs)
36 * @brief Funcion privada usada para añadir grupos de aulas recursivamente
37 * @param classroomGroups Grupos de aulas que pueden contener más grupos
38 * @param rs resultset de la consulta a la base de datos.
39 */
40function addClassroomGroup(&$classroomGroups, $rs){
41
42        array_walk($classroomGroups, function(&$group,$key){
43                global $rs;
44                if (isset($group['id']) && $group['id'] === $rs->campos["group_group_id"]) {
45                        array_push($group["classroomGroups"],array("id" => $rs->campos["group_id"],
46                                "name" => $rs->campos["nombregrupoordenador"],
47                                "comments" => $rs->campos["comentarios"],
48                                "classroomGroups" => array()));
49                }
50                else if(count($group["classroomGroups"]) > 0){
51                        addClassroomGroup($group["classroomGroups"], $rs);
52                }
53                /**/
54        });
55}
[fb2ee20]56
[2a337db]57/**
58 * @fn    getStatus(ouid, labid, [clntid])
59 * @brief    Returns client execution status or status of all lab's clients.
[43f3bde]60 * @param    int ouid    OU id.
61 * @param    int labid   Lab. id.
62 * @param    int clntid  Client id. (optional)
63 * @return   string      JSON object or array of objects including status data.
[2a337db]64 */
65function getStatus($ouid, $labid, $clntid=0) {
66        global $userid;
67        global $cmd;
68        global $LONCABECERA;
69        global $LONHEXPRM;
[16491c9]70        $app = \Slim\Slim::getInstance();
[43f3bde]71        $response = [];
72        $id = [];
73        $stat = [];
74        $ip = "";
[16491c9]75        $urls = [];
[2a337db]76        // Status mapping.
[16491c9]77        $status = ['OFF'=>"off",
78                   'INI'=>"initializing",
79                   'OPG'=>"oglive",
80                   'BSY'=>"busy",
81                   'LNX'=>"linux",
82                   'OSX'=>"macos",
83                   'WIN'=>"windows",
84                   'UNK'=>"unknown"];
[2a337db]85        // Parameters.
86        $ouid = htmlspecialchars($ouid);
87        $labid = htmlspecialchars($labid);
88        $single = is_numeric(explode("/", $app->request->getResourceUri())[6]);
89
90        // Database query.
91        $cmd->texto = <<<EOD
[dbb1b6c]92SELECT adm.idusuario, aulas.idaula, ordenadores.idordenador, ordenadores.ip
93  FROM ordenadores
[2a337db]94  JOIN aulas USING(idaula)
95 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[9199fc7]96 WHERE adm.idusuario = '$userid'
[2a337db]97   AND adm.idcentro='$ouid'
98   AND aulas.idaula='$labid'
99EOD;
100        // Request for a single client.
101        if ($single) {
102                $clntid = htmlspecialchars($clntid);
103                $cmd->texto .= <<<EOD
104   AND ordenadores.idordenador='$clntid';
105EOD;
106        }
107        $rs=new Recordset;
108        $rs->Comando=&$cmd;
109        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
110        $rs->Primero();
111        // Check if user is an UO admin and asset exists.
[9199fc7]112        if (checkAdmin($rs->campos["idusuario"]) and (($single and checkParameter($rs->campos["idordenador"])) or (! $single and checkParameter($rs->campos["idaula"])))) {
[2a337db]113                while (!$rs->EOF) {
114                        $id[$rs->campos["ip"]] = $rs->campos["idordenador"];
115                        $stat[$rs->campos["ip"]] = $status['OFF'];
116                        $rs->Siguiente();
117                }
[dbb1b6c]118                // Get client status.
[2a337db]119                $clientid = implode(",", $id);
120                $clientip = implode(";", array_keys($id));
[dbb1b6c]121                $result = clients(2, $clientip);
[16491c9]122                // Check status type.
123                if (checkParameter($result)) {
124                        foreach (explode(";", $result) as $data) {
125                                if (!empty($data)) {
126                                        list($clip, $clst) = explode("/", $data);
127                                        if ($clst != "OFF") {
128                                                // Update current status.
129                                                $stat[$clip] = $status[$clst];
[2a337db]130                                        }
131                                }
132                        }
[16491c9]133                }
134                // Prepare request to new OGAgent for OSes.
135                foreach ($stat as $ip => $st) {
136                        if ($st == "off") {
137                                $urls[$ip] = "https://$ip:8000/opengnsys/status";
[2a337db]138                        }
[16491c9]139                }
140                // Send request to OGAgents.
141                if (isset($urls)) {
142                        $result = multiRequest($urls);
143                }
144                // Parse responses.
145                reset($urls);
146                foreach ($result as $res) {
147                        if (!empty($res['data'])) {
148                                // Get status and session data.
149                                $ip = key($urls);
150                                $data = json_decode($res['data']);
151                                if (@isset($status[$data->status])) {
152                                        $stat[$ip] = $status[$data->status];
153                                        $logged[$ip] = $data->loggedin;
154                                } else {
155                                        $stat[$ip] = $status['UNK'];
[2a337db]156                                }
157                        }
[16491c9]158                        unset($urls[$ip]);
159                }
160                // Compose JSON response.
161                if ($single) {
162                        // Single response.
163                        $response['id'] = (int)reset($id);
164                        $response['ip'] = key($id);
165                        $response['status'] = $stat[key($id)];
166                        empty($logged[$ip]) || $response['loggedin'] = $logged[$ip];
[2a337db]167                } else {
[16491c9]168                        // Multiple responses.
169                        foreach ($stat as $ip => $st) {
[a9a6da5e]170                                if (isset($id[$ip])) {
171                                        $tmp = ['id' => (int)$id[$ip],
172                                                'ip' => $ip,
173                                                'status' => $stat[$ip]];
174                                        empty($logged[$ip]) || $tmp['loggedin'] = $logged[$ip];
175                                        array_push($response, $tmp);
176                                }
[16491c9]177                        }
[2a337db]178                }
[16491c9]179                jsonResponse(200, $response);
[2a337db]180        }
181        $rs->Cerrar();
182}
183
[fb2ee20]184
[3551804]185// REST routes.
[fb2ee20]186
187/**
188 * @brief    user login.
189 * @note     Route: /login, Method: POST
190 * @param    string username   User name.
191 * @param    string password   User password.
192 * @return   string            JSON response with user id. and API key.
193 * @note     User's API key is stored in a new field of "usuarios" table.
194 */
195$app->post('/login',
196    function() use ($app) {
197        global $cmd;
198        global $userid;
199
[5ff84a5]200        $response = Array();
[fb2ee20]201        // Reading JSON parameters.
202        try {
203                $input = json_decode($app->request()->getBody());
204                $user = htmlspecialchars($input->username);
205                $pass = htmlspecialchars($input->password);
206        } catch (Exception $e) {
[29bc749]207                // Error message.
[fb2ee20]208                $response["message"] = $e->getMessage();
209                jsonResponse(400, $response);
210                $app->stop();
211        }
212
[3551804]213        // Checking parameters.
[fb2ee20]214        if (! empty($user) and ! empty($pass)) {
215                // Database query.
216                $cmd->texto = "SELECT idusuario, apikey
217                                 FROM usuarios
[7441e57]218                                WHERE usuario='$user' AND pasguor=SHA2('$pass',224)";
[fb2ee20]219                $rs=new Recordset;
220                $rs->Comando=&$cmd;
221                if ($rs->Abrir()) {
222                        $rs->Primero();
223                        if (!$rs->EOF){
224                                // JSON response.
225                                $userid=$rs->campos["idusuario"];
226                                $apikey=$rs->campos["apikey"];
227                                $response['userid'] = $userid;
228                                $response['apikey'] = $apikey;
229                                jsonResponse(200, $response);
230                        } else {
231                                // Credentials error.
232                                $response['message'] = 'Login failed. Incorrect credentials';
233                                jsonResponse(401, $response);
234                                $app->stop();
235                        }
236                        $rs->Cerrar();
237                } else {
238                        // Access error.
239                        $response['message'] = "An error occurred. Please try again";
240                        jsonResponse(500, $response);
241                        $app->stop();
242                }
243        } else {
244                # Error: missing some input parameter.
245                $response['message'] = 'Missing username or password';
246                jsonResponse(400, $response);
247                $app->stop();
248        }
249    }
250);
251
252/**
253 * @brief    List all defined Organizational Units
254 * @note     Route: /ous, Method: GET
[43f3bde]255 * @return   string  JSON array with id. and name for every defined OU
[fb2ee20]256 */
[18391d1]257$app->get('/ous(/)', function() {
[fb2ee20]258        global $cmd;
259
260        $cmd->texto = "SELECT * FROM centros";
261        $rs=new Recordset;
262        $rs->Comando=&$cmd;
[2aa8687]263        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[5ff84a5]264        $response = Array();
[fb2ee20]265        $rs->Primero();
266        while (!$rs->EOF) {
[5ff84a5]267                $tmp = Array();
[ffaf580]268                $tmp['id'] = (int)$rs->campos["idcentro"];
[1485b99]269                $tmp['name'] = $rs->campos["nombrecentro"];
[4a511f81]270                array_push($response, $tmp);
[fb2ee20]271                $rs->Siguiente();
272        }
273        $rs->Cerrar();
274        jsonResponse(200, $response);
[3551804]275   }
[fb2ee20]276);
277
278/**
279 * @brief    Get Organizational Unit data
[43f3bde]280 * @note     Route: /ous/:ouid, Method: GET
281 * @param    int ouid  OU id.
282 * @return   string    JSON string with OU's parameters
[fb2ee20]283 */
[18391d1]284$app->get('/ous/:ouid(/)', 'validateApiKey',
[fb2ee20]285    function($ouid) {
286        global $cmd;
[18391d1]287        global $userid;
[fb2ee20]288
289        $ouid = htmlspecialchars($ouid);
[18391d1]290        // Show OU information if user is OU's admin.
291        $cmd->texto = <<<EOD
292SELECT *
293  FROM centros
294 RIGHT JOIN administradores_centros USING(idcentro)
[9199fc7]295 WHERE administradores_centros.idusuario = '$userid'
[18391d1]296   AND centros.idcentro = '$ouid'
297 LIMIT 1;
298EOD;
[fb2ee20]299        $rs=new Recordset;
300        $rs->Comando=&$cmd;
[2aa8687]301        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]302        $rs->Primero();
[9199fc7]303        if (checkAdmin($rs->campos["idusuario"]) and
[18391d1]304            checkParameter($rs->campos["idcentro"])) {
[ffaf580]305                $response['id'] = (int)$ouid;
[bbc672f]306                $response['name'] = $rs->campos["nombrecentro"];
[fb2ee20]307                $response['description'] = $rs->campos["comentarios"];
308                jsonResponse(200, $response);
309        }
310        $rs->Cerrar();
311    }
312);
313
[18391d1]314/**
315 * @brief    List group of labs in an Organizational Unit
[43f3bde]316 * @note     Route: /ous/:ouid/groups, Method: GET
317 * @param    int ouid   OU id.
318 * @return   string      JSON array of OU groups
[18391d1]319 */
320$app->get('/ous/:ouid/groups(/)', 'validateApiKey', function($ouid) {
[23a72c0]321        global $cmd;
322        global $userid;
323
324        $ouid = htmlspecialchars($ouid);
[18391d1]325        // List group of labs if user is OU's admin.
326        $cmd->texto = <<<EOD
[9199fc7]327SELECT adm.idusuario, grupos.*
[18391d1]328  FROM grupos
329 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[9199fc7]330 WHERE adm.idusuario = '$userid'
[18391d1]331   AND idcentro='$ouid';
332EOD;
333        $rs=new Recordset;
334        $rs->Comando=&$cmd;
[2aa8687]335        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[18391d1]336        $rs->Primero();
337        // Check if user is an UO admin.
[9199fc7]338        if (checkAdmin($rs->campos["idusuario"])) {
[5ff84a5]339                $response = Array();
[18391d1]340                // Read data.
341                if (! is_null($rs->campos["idcentro"])) {
342                        while (!$rs->EOF) {
[5ff84a5]343                                $tmp = Array();
[ffaf580]344                                $tmp['id'] = (int)$rs->campos["idgrupo"];
[18391d1]345                                $tmp['name'] = $rs->campos["nombregrupo"];
346                                $tmp['type'] = $rs->campos["tipo"];
347                                $tmp['comments'] = $rs->campos["comentarios"];
[23a72c0]348                                if($rs->campos["grupoid"] != 0){
[ffaf580]349                                        $tmp['parent']['id'] = (int)$rs->campos["grupoid"];
[23a72c0]350                                }
351                                array_push($response, $tmp);
352                                $rs->Siguiente();
353                        }
354                }
[18391d1]355                jsonResponse(200, $response);
[23a72c0]356        }
[18391d1]357        $rs->Cerrar();
[23a72c0]358    }
359);
360
[ac8b234e]361/**
362 * @brief    List all labs defined in an OU
[43f3bde]363 * @note     Route: /ous/:ouid/labs, Method: GET
364 * @param    int ouid  OU id.
365 * @return   string    JSON array of all UO's labs data
[ac8b234e]366 */
[18391d1]367$app->get('/ous/:ouid/labs(/)', 'validateApiKey',
[fb2ee20]368    function($ouid) {
[606a0c7]369        global $userid;
[fb2ee20]370        global $cmd;
371
372        $ouid = htmlspecialchars($ouid);
[2aa8687]373        // Database query.
[fb2ee20]374        $cmd->texto = <<<EOD
[9199fc7]375SELECT adm.idusuario, aulas.*, grp.idgrupo AS group_id,
[606a0c7]376       grp.nombregrupoordenador, grp.grupoid AS group_group_id, grp.comentarios
[fb2ee20]377  FROM aulas
378 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[606a0c7]379  LEFT JOIN gruposordenadores AS grp USING(idaula)
[9199fc7]380 WHERE adm.idusuario = '$userid'
[5ff84a5]381   AND adm.idcentro='$ouid'
[606a0c7]382 ORDER BY aulas.idaula, grp.idgrupo
[fb2ee20]383EOD;
384        $rs=new Recordset;
385        $rs->Comando=&$cmd;
[606a0c7]386        if (!$rs->Abrir()) return(false);       // Error opening recordset.
[18391d1]387        // Check if user is an UO admin.
[fb2ee20]388        $rs->Primero();
[9199fc7]389        if (checkAdmin($rs->campos["idusuario"])) {
[5ff84a5]390                $response = Array();
[18391d1]391                if (! is_null($rs->campos["idcentro"])) {
392                        while (!$rs->EOF) {
393                                // En los resultados las aulas vienen repetidas tantas veces como grupos tengan, solo dejamos uno
394                                $classroomIndex = -1;
395                                $found=false;
396                                $index = 0;
397                                while(!$found && $index < count($response)){
398                                        if(isset($response[$index]["id"]) && $response[$index]["id"] == $rs->campos["idaula"]){
399                                                $classroomIndex = $index;
400                                                $found = true;
401                                        }
402                                        $index++;
[606a0c7]403                                }
[18391d1]404                                if(!$found){
[5ff84a5]405                                        $tmp = Array();
[ffaf580]406                                        $tmp['id'] = (int)$rs->campos["idaula"];
[18391d1]407                                        $tmp['name'] = $rs->campos["nombreaula"];
[43f3bde]408                                        $tmp['inremotepc'] = ($rs->campos["inremotepc"] == 1);
[ffaf580]409                                        $tmp['group']['id'] = (int)$rs->campos["grupoid"];
[fa2b1244]410                                        $tmp['classroomGroups'] = array();
411                                        if (isset($rs->campos["nombregrupoordenador"])){
412                                                $tmp['classroomGroups'] = array(array("id" => (int)$rs->campos["group_id"], "name" => $rs->campos["nombregrupoordenador"], "comments" => $rs->campos["comentarios"], "classroomGroups" => array()));
413                                        }
[ffaf580]414                                        $tmp['ou']['id'] = (int)$ouid;
[18391d1]415                                        array_push($response, $tmp);
[606a0c7]416                                }
[18391d1]417                                else{
418                                        // Le añadimos el grupo en cuestion siempre que no sea un subgrupo
419                                        if($rs->campos["group_group_id"] == 0){
420                                                array_push($response[$classroomIndex]['classroomGroups'],
[ffaf580]421                                                        array("id" => (int)$rs->campos["group_id"],
[18391d1]422                                                        "name" => $rs->campos["nombregrupoordenador"],
423                                                        "comments" => $rs->campos["comentarios"],
424                                                        "classroomGroups" => array()));
425                                        }
426                                        else {
427                                                // Buscamos el grupo donde añadir el grupo
428                                                addClassroomGroup($response[$classroomIndex]['classroomGroups'], $rs);
429                                        }
[606a0c7]430                                }
[18391d1]431                                $rs->Siguiente();
[606a0c7]432                        }
[fb2ee20]433                }
434                jsonResponse(200, $response);
435        }
436        $rs->Cerrar();
437    }
438);
439
[ac8b234e]440/**
441 * @brief    Get lab data
[43f3bde]442 * @note     Route: /ous/:ouid/labs/:labid, Method: GET
443 * @param    int ouid   OU id.
444 * @param    int labid  lab id.
445 * @return   string     JSON string with lab parameters
[ac8b234e]446 */
[4139899]447$app->get('/ous/:ouid/labs/:labid(/)', 'validateApiKey',
[fb2ee20]448    function($ouid, $labid) {
[4139899]449        global $userid;
[fb2ee20]450        global $cmd;
451
452        $ouid = htmlspecialchars($ouid);
453        $labid = htmlspecialchars($labid);
[2aa8687]454        // Database query.
[fb2ee20]455        $cmd->texto = <<<EOD
[9199fc7]456SELECT adm.idusuario, COUNT(idordenador) AS defclients, aulas.*
[fb2ee20]457  FROM aulas
458 RIGHT JOIN administradores_centros AS adm USING(idcentro)
459  LEFT JOIN ordenadores USING(idaula)
[9199fc7]460 WHERE adm.idusuario = '$userid'
[4139899]461   AND idcentro='$ouid'
[fb2ee20]462   AND idaula='$labid';
463EOD;
464        $rs=new Recordset;
465        $rs->Comando=&$cmd;
[2aa8687]466        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]467        $rs->Primero();
[4139899]468        // Check if user is an UO admin and lab exists.
[9199fc7]469        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["idaula"])) {
[ffaf580]470                $response['id'] = (int)$rs->campos["idaula"];
[bbc672f]471                $response['name'] = $rs->campos["nombreaula"];
472                $response['location'] = $rs->campos["ubicacion"];
[fb2ee20]473                $response['description'] = $rs->campos["comentarios"];
[43f3bde]474                $response['inremotepc'] = ($rs->campos["inremotepc"] == 1);
[ffaf580]475                $response['capacity'] = (int)$rs->campos["puestos"];
[43f3bde]476                if ($rs->campos["idordprofesor"]) {
477                        $response['profclient']['id'] = (int)$rs->campos["idordprofesor"];
478                }
[ffaf580]479                $response['defclients'] = (int)$rs->campos["defclients"];
[43f3bde]480                $response['projector'] = ($rs->campos["cagnon"] == 1);
481                $response['board'] = ($rs->campos["pizarra"] == 1);
[fb2ee20]482                $response['routerip'] = $rs->campos["router"];
483                $response['netmask'] = $rs->campos["netmask"];
484                $response['ntp'] = $rs->campos["ntp"];
485                $response['dns'] = $rs->campos["dns"];
486                $response['proxyurl'] = $rs->campos["proxy"];
487                switch ($rs->campos["modomul"]) {
488                        case 1:  $response['mcastmode'] = "half-duplex"; break;
489                        case 2:  $response['mcastmode'] = "full-duplex"; break;
490                        default: $response['mcastmode'] = $rs->campos["modomul"];
491                }
492                $response['mcastip'] = $rs->campos["ipmul"];
493                $response['mcastport'] = $rs->campos["pormul"];
494                $response['mcastspeed'] = $rs->campos["velmul"];
495                $response['p2pmode'] = $rs->campos["modp2p"];
496                $response['p2ptime'] = $rs->campos["timep2p"];
[0126b05]497                $response['picture'] = $rs->campos["urlfoto"];
[fb2ee20]498                jsonResponse(200, $response);
499        }
500        $rs->Cerrar();
501    }
502);
503
[213a832]504
[4139899]505/**
506 * @brief    List all clients defined in a lab
[43f3bde]507 * @note     Route: /ous/:ouid/labs/:labid/clients, Method: GET
508 * @param    int ouid   OU id.
509 * @param    int labid  lab id.
510 * @return   string     JSON data with lab id. and array of lab parameters
[4139899]511 */
512$app->get('/ous/:ouid/labs/:labid/clients(/)', 'validateApiKey',
[fb2ee20]513    function($ouid, $labid) {
[4139899]514        global $userid;
[fb2ee20]515        global $cmd;
516
517        $ouid = htmlspecialchars($ouid);
518        $labid = htmlspecialchars($labid);
[2aa8687]519        // Database query.
[fb5338c]520        $cmd->texto = <<<EOD
[9199fc7]521SELECT adm.idusuario, ordenadores.*, aulas.idaula AS labid
[fb5338c]522  FROM ordenadores
[4139899]523 RIGHT JOIN aulas USING(idaula)
[fb5338c]524 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[9199fc7]525 WHERE adm.idusuario = '$userid'
[2aa8687]526   AND adm.idcentro='$ouid'
527   AND aulas.idaula='$labid';
[fb5338c]528EOD;
[fb2ee20]529        $rs=new Recordset;
530        $rs->Comando=&$cmd;
[2aa8687]531        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]532        $rs->Primero();
[4139899]533        // Check if user is an UO admin and lab exists.
[9199fc7]534        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["labid"])) {
[5ff84a5]535                $response = Array();
[fb2ee20]536                while (!$rs->EOF) {
[4139899]537                        if (!is_null($rs->campos["idordenador"])) {
[5ff84a5]538                                $tmp = Array();
[ffaf580]539                                $tmp['id'] = (int)$rs->campos["idordenador"];
[4139899]540                                $tmp['name'] = $rs->campos["nombreordenador"];
541                                $tmp['ip'] = $rs->campos["ip"];
542                                $tmp['mac'] = $rs->campos["mac"];
[ffaf580]543                                $tmp['ou']['id'] = (int)$ouid;
544                                $tmp['lab']['id'] = (int)$labid;
[4139899]545                                array_push($response, $tmp);
546                        }
[fb2ee20]547                        $rs->Siguiente();
548                }
549                jsonResponse(200, $response);
550        }
551        $rs->Cerrar();
552    }
553);
554
[4139899]555/**
[2a337db]556 * @brief    Get execution status of all clients defined in a lab
[43f3bde]557 * @note     Route: /ous/:ouid/labs/:labid/clients/:clntid/status, Method: GET
558 * @param    int ouid   OU id.
559 * @param    int labid  lab id.
560 * @return   string     JSON string with array of all client status defined in a lab
[2a337db]561 */
562$app->get('/ous/:ouid/labs/:labid/clients/status(/)', 'validateApiKey', 'getStatus');
563
564/**
[4139899]565 * @brief    Get client data
566 * @note     Route: /ous/id1/labs/id2clients/id3, Method: GET
[43f3bde]567 * @param    int ouid    OU id.
568 * @param    int labid   lab id.
569 * @param    int clntid  client id.
570 * @return   string      JSON string with hardware parameters
[4139899]571 */
572$app->get('/ous/:ouid/labs/:labid/clients/:clntid(/)', 'validateApiKey',
[fb2ee20]573    function($ouid, $labid, $clntid) {
[4139899]574        global $userid;
[fb2ee20]575        global $cmd;
576
577        $ouid = htmlspecialchars($ouid);
578        $labid = htmlspecialchars($labid);
579        $clntid = htmlspecialchars($clntid);
[2aa8687]580        // Database query.
[fb5338c]581        $cmd->texto = <<<EOD
[9199fc7]582SELECT adm.idusuario, ordenadores.*,
[43f3bde]583       IF(ordenadores.idordenador=aulas.idordprofesor, 1, 0) AS profclient
[fb5338c]584  FROM ordenadores
585  JOIN aulas USING(idaula)
586 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[9199fc7]587 WHERE adm.idusuario = '$userid'
[4139899]588   AND idcentro='$ouid'
[fb5338c]589   AND idaula='$labid'
590   AND idordenador='$clntid';
591EOD;
[fb2ee20]592        $rs=new Recordset;
593        $rs->Comando=&$cmd;
[2aa8687]594        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]595        $rs->Primero();
[4139899]596        // Check if user is an UO admin, lab exists and client exists.
[9199fc7]597        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["idaula"]) and checkParameter($rs->campos["idordenador"])) {
[2aa8687]598                // Read data.
[ffaf580]599                $response['id'] = (int)$rs->campos["idordenador"];
[bbc672f]600                $response['name'] = $rs->campos["nombreordenador"];
601                $response['serialno'] = $rs->campos["numserie"];
[fb2ee20]602                $response['netiface'] = $rs->campos["netiface"];
603                $response['netdriver'] = $rs->campos["netdriver"];
604                $response['mac'] = $rs->campos["mac"];
605                $response['ip'] = $rs->campos["ip"];
606                $response['netmask'] = $rs->campos["mascara"];
607                $response['routerip'] = $rs->campos["router"];
[ffaf580]608                $response['repo']['id'] = (int)$rs->campos["idrepositorio"];
[43f3bde]609                $response['profclient'] = ($rs->campos["profclient"] == 1);
[4a511f81]610                //$response['hardprofile']['id'] = $rs->campos["idperfilhard"];
611                //$response['menu']['id'] = $rs->campos["idmenu"];
[43f3bde]612                $response['validation'] = ($rs->campos["validacion"] == 1);
[fb5338c]613                $response['boottype'] = $rs->campos["arranque"];
[0126b05]614                $response['picture'] = $rs->campos["fotoord"];
[fb2ee20]615                jsonResponse(200, $response);
616        }
617        $rs->Cerrar();
618    }
619);
620
[2aa8687]621/**
622 * @brief    Get client's harware configuration data
[43f3bde]623 * @note     Route: /ous/:ouid/labs/:labid/clients/:clntid/hardware, Method: GET
624 * @param    int ouid    OU id.
625 * @param    int labid   lab id.
626 * @param    int clntid  client id.
627 * @return   string      JSON string with cleint parameters
[2aa8687]628 */
629$app->get('/ous/:ouid/labs/:labid/clients/:clntid/hardware(/)', 'validateApiKey',
[fb2ee20]630    function($ouid, $labid, $clntid) {
[4139899]631        global $userid;
[fb2ee20]632        global $cmd;
633
634        $ouid = htmlspecialchars($ouid);
635        $labid = htmlspecialchars($labid);
636        $clntid = htmlspecialchars($clntid);
[2aa8687]637        // Database query.
[fb2ee20]638        $cmd->texto = <<<EOD
[9199fc7]639SELECT adm.idusuario, ordenadores.idordenador, ordenadores.nombreordenador,
[fb2ee20]640       tipohardwares.nemonico, hardwares.descripcion
[2aa8687]641  FROM ordenadores
642  JOIN aulas USING(idaula)
643 RIGHT JOIN administradores_centros AS adm USING(idcentro)
644  LEFT JOIN perfileshard_hardwares USING(idperfilhard)
645  LEFT JOIN hardwares ON perfileshard_hardwares.idhardware=hardwares.idhardware
646  LEFT JOIN tipohardwares ON tipohardwares.idtipohardware=hardwares.idtipohardware
[9199fc7]647 WHERE adm.idusuario = '$userid'
[2aa8687]648   AND adm.idcentro='$ouid'
649   AND aulas.idaula='$labid'
650   AND ordenadores.idordenador='$clntid';
[fb2ee20]651EOD;
652        $rs=new Recordset;
653        $rs->Comando=&$cmd;
[2aa8687]654        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]655        $rs->Primero();
[2aa8687]656        // Check if user is an UO admin and client exists.
[9199fc7]657        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["idordenador"])) {
[2aa8687]658                // Read data.
[ffaf580]659                $response['id'] = (int)$rs->campos["idordenador"];
[bbc672f]660                $response['name'] = $rs->campos["nombreordenador"];
[5ff84a5]661                $response['hardware'] = Array();
[fb2ee20]662                while (!$rs->EOF) {
[2aa8687]663                        if (!is_null($rs->campos["nemonico"])) {
[5ff84a5]664                                $tmp = Array();
[2aa8687]665                                $tmp['type'] = $rs->campos["nemonico"];
666                                $tmp['description'] = $rs->campos["descripcion"];
667                                array_push($response['hardware'], $tmp);
668                        }
[fb2ee20]669                        $rs->Siguiente();
670                }
671                jsonResponse(200, $response);
672        }
673        $rs->Cerrar();
674    }
675);
676
[2aa8687]677/**
678 * @brief    Get client's disk configuration data
[43f3bde]679 * @note     Route: /ous/:ouid1/labs/:labid/clients/:clntid/diskcfg, Method: GET
680 * @param    int ouid    OU id.
681 * @param    int labid   lab id.
682 * @param    int clntid  client id.
683 * @return   string      JSON string with disk parameters
[2aa8687]684 */
685$app->get('/ous/:ouid/labs/:labid/clients/:clntid/diskcfg(/)', 'validateApiKey',
[fb2ee20]686    function($ouid, $labid, $clntid) {
[2aa8687]687        global $userid;
[fb2ee20]688        global $cmd;
689
690        $ouid = htmlspecialchars($ouid);
691        $labid = htmlspecialchars($labid);
692        $clntid = htmlspecialchars($clntid);
[2aa8687]693        // Database query.
[fb2ee20]694        $cmd->texto = <<<EOD
[9199fc7]695SELECT adm.idusuario, ordenadores.idordenador AS clientid,
[2aa8687]696       ordenadores.nombreordenador, ordenadores_particiones.*, tipospar.tipopar,
[208ee50]697       sistemasficheros.nemonico, nombresos.nombreso, imagenes.nombreca,
698       (imagenes.revision - ordenadores_particiones.revision) AS difimagen
[fb2ee20]699  FROM ordenadores_particiones
700 RIGHT JOIN ordenadores USING(idordenador)
[2aa8687]701  JOIN aulas USING(idaula)
702 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[fb2ee20]703  LEFT JOIN tipospar USING(codpar)
704  LEFT JOIN sistemasficheros USING(idsistemafichero)
705  LEFT JOIN nombresos USING(idnombreso)
706  LEFT JOIN imagenes USING(idimagen)
[9199fc7]707 WHERE adm.idusuario = '$userid'
[2aa8687]708   AND adm.idcentro='$ouid'
709   AND aulas.idaula='$labid'
710   AND ordenadores.idordenador='$clntid'
[fb2ee20]711 ORDER BY numdisk ASC, numpar ASC;
712EOD;
713        $rs=new Recordset;
714        $rs->Comando=&$cmd;
[2aa8687]715        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]716        $rs->Primero();
[2aa8687]717        // Check if user is an UO admin and client exists.
[9199fc7]718        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["clientid"])) {
[2aa8687]719                // Read data.
[ffaf580]720                $response['id'] = (int)$rs->campos["clientid"];
[bbc672f]721                $response['name'] = $rs->campos["nombreordenador"];
[5ff84a5]722                $response['diskcfg'] = Array();
[fb2ee20]723                while (!$rs->EOF) {
[d57fcbc]724                        // Skip header.
[fb2ee20]725                        if ($rs->campos["numdisk"] == 0) {
726                                $rs->Siguiente();
727                                continue;
728                        }
[5ff84a5]729                        $tmp = Array();
[2fd9054]730                        // Common data.
[ffaf580]731                        $tmp['disk'] = (int)$rs->campos["numdisk"];
732                        $tmp['size'] = (int)$rs->campos["tamano"];
[fb2ee20]733                        if ($rs->campos["numpar"] == 0) {
[2aa8687]734                                // Disk data.
[fb2ee20]735                                switch ($rs->campos["codpar"]) {
736                                        case 1:  $tmp['parttable'] = "MSDOS"; break;
737                                        case 2:  $tmp['parttable'] = "GPT"; break;
738                                        case 3:  $tmp['parttable'] = "LVM"; break;
739                                        case 4:  $tmp['parttable'] = "ZPOOL"; break;
740                                        default: $tmp['parttable'] = $rs->campos["codpar"];
741                                }
742                        } else {
[2aa8687]743                                // Partition data.
[ffaf580]744                                $tmp['partition'] = (int)$rs->campos["numpar"];
[fb2ee20]745                                $tmp['parttype'] = $rs->campos["tipopar"];
746                                $tmp['filesystem'] = $rs->campos["nemonico"];
[ffaf580]747                                $tmp['usage'] = (int)$rs->campos["uso"];
[fb2ee20]748                                if ($rs->campos["nombreso"] != null) {
749                                        $tmp['os'] = $rs->campos["nombreso"];
[df81ab78]750                                        if ($rs->campos["idimagen"] > 0) {
[2aa8687]751                                                // Restored image data.
[ffaf580]752                                                $tmp['image']['id'] = (int)$rs->campos["idimagen"];
[df81ab78]753                                                $tmp['image']['deploydate'] = $rs->campos["fechadespliegue"];
[2aa8687]754                                                // Check if image is updated.
[43f3bde]755                                                $tmp['image']['updated'] = ($rs->campos["difimagen"] == 0);
[df81ab78]756                                        }
[fb2ee20]757                                }
758                                //$tmp['cachedata'] = $rs->campos["cache"];
759                        }
760                        array_push($response['diskcfg'], $tmp);
761                        $rs->Siguiente();
762                }
763                jsonResponse(200, $response);
764        }
765        $rs->Cerrar();
766    }
767);
768
[2aa8687]769/**
770 * @brief    Get client's execution status
[43f3bde]771 * @note     Route: /ous/:ouid/labs/:labid/clients/:clntid/status, Method: GET
772 * @param    int ouid    OU id.
773 * @param    int labid   lab id.
774 * @param    int clntid  client id.
775 * @return   string      JSON string with client status
[2aa8687]776 */
[213a832]777$app->get('/ous/:ouid/labs/:labid/clients/:clntid/status(/)', 'validateApiKey', 'getStatus');
[fb2ee20]778
[2aa8687]779/**
780 * @brief    List all image repositories defined in an OU
781 * @note     Route: /ous/id/repos, Method: GET
[43f3bde]782 * @param    int ouid  OU id.
783 * @return   string    JSON array of all UO's repo data
[2aa8687]784 */
785$app->get('/ous/:ouid/repos(/)', 'validateApiKey',
[fb2ee20]786    function($ouid) {
[2aa8687]787        global $userid;
[fb2ee20]788        global $cmd;
789
790        $ouid = htmlspecialchars($ouid);
[2aa8687]791        // Database query.
792        $cmd->texto = <<<EOD
[9199fc7]793SELECT adm.idusuario, adm.idcentro AS ouid, repositorios.*
[2aa8687]794  FROM repositorios
795 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[9199fc7]796 WHERE adm.idusuario = '$userid'
[2aa8687]797   AND adm.idcentro='$ouid';
798EOD;
[fb2ee20]799        $rs=new Recordset;
800        $rs->Comando=&$cmd;
[2aa8687]801        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]802        $rs->Primero();
[2aa8687]803        // Check if user is an UO admin.
[9199fc7]804        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["ouid"])) {
[5ff84a5]805                $response = Array();
[fb2ee20]806                while (!$rs->EOF) {
[2aa8687]807                        if (! is_null($rs->campos["idcentro"])) {
[5ff84a5]808                                $tmp = Array();
[ffaf580]809                                $tmp['id'] = (int)$rs->campos["idrepositorio"];
[2aa8687]810                                $tmp['name'] = $rs->campos["nombrerepositorio"];
[ffaf580]811                                $tmp['ou']['id'] = (int)$ouid;
[2aa8687]812                                array_push($response, $tmp);
813                        }
[fb2ee20]814                        $rs->Siguiente();
815                }
816                jsonResponse(200, $response);
817        }
818        $rs->Cerrar();
819    }
820);
821
[2aa8687]822/**
823 * @brief    Get image repository data
[43f3bde]824 * @note     Route: /ous/:ouid/repos/:repoid, Method: GET
825 * @param    int ouid    OU id.
826 * @param    int repoid  repository id.
827 * @return   string      JSON string with repo parameters
[2aa8687]828 */
829$app->get('/ous/:ouid/repos/:repoid(/)', 'validateApiKey',
[fb2ee20]830    function($ouid, $repoid) {
[2aa8687]831        global $userid;
[fb2ee20]832        global $cmd;
833
834        $ouid = htmlspecialchars($ouid);
835        $repoid = htmlspecialchars($repoid);
[2aa8687]836        // Database query.
837        $cmd->texto = <<<EOD
[9199fc7]838SELECT adm.idusuario, repositorios.*
[2aa8687]839  FROM repositorios
840 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[9199fc7]841 WHERE adm.idusuario = '$userid'
[2aa8687]842   AND adm.idcentro='$ouid'
843   AND idrepositorio='$repoid';
844EOD;
[fb2ee20]845        $rs=new Recordset;
846        $rs->Comando=&$cmd;
[2aa8687]847        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]848        $rs->Primero();
[2aa8687]849        // Check if user is an UO admin and repo exists.
[9199fc7]850        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["idrepositorio"])) {
[2aa8687]851                // Read data.
[ffaf580]852                $response['id'] = (int)$rs->campos["idrepositorio"];
[bbc672f]853                $response['name'] = $rs->campos["nombrerepositorio"];
[fb2ee20]854                $response['description'] = $rs->campos["comentarios"];
[4a511f81]855                $response['ip'] = $rs->campos["ip"];
[fb2ee20]856                jsonResponse(200, $response);
857        }
858        $rs->Cerrar();
859    }
860);
861
[5ff84a5]862/**
863 * @brief    List all images defined in an OU
[43f3bde]864 * @note     Route: /ous/:ouid/images, Method: GET
865 * @param    int ouid  OU id.
866 * @return   string    JSON array of all UO's image data
[5ff84a5]867 */
868$app->get('/ous/:ouid/images(/)', 'validateApiKey',
[fb2ee20]869    function($ouid) {
[5ff84a5]870        global $userid;
[fb2ee20]871        global $cmd;
872
873        $ouid = htmlspecialchars($ouid);
[5ff84a5]874        // Database query.
875        $cmd->texto = <<<EOD
[9199fc7]876SELECT adm.idusuario, adm.idcentro AS ouid, imagenes.*
[5ff84a5]877  FROM imagenes
878 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[9199fc7]879 WHERE adm.idusuario = '$userid'
[5ff84a5]880   AND adm.idcentro='$ouid';
881EOD;
[fb2ee20]882        $rs=new Recordset;
883        $rs->Comando=&$cmd;
[5ff84a5]884        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]885        $rs->Primero();
[5ff84a5]886        // Check if user is an UO admin.
[9199fc7]887        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["ouid"])) {
[5ff84a5]888                $response = Array();
[fb2ee20]889                while (!$rs->EOF) {
[5ff84a5]890                        if (! is_null($rs->campos["idcentro"])) {
891                                $tmp = Array();
[ffaf580]892                                $tmp['id'] = (int)$rs->campos["idimagen"];
[5ff84a5]893                                $tmp['name'] = $rs->campos["nombreca"];
[43f3bde]894                                $tmp['inremotepc'] = ($rs->campos["inremotepc"] == 1);
[ffaf580]895                                $tmp['ou']['id'] = (int)$ouid;
[5ff84a5]896                                array_push($response, $tmp);
897                        }
[fb2ee20]898                        $rs->Siguiente();
899                }
900                jsonResponse(200, $response);
901        }
902    }
903);
904
[5ff84a5]905/**
906 * @brief    Get image data
[43f3bde]907 * @note     Route: /ous/:ouid/images/:imgid, Method: GET
908 * @param    int ouid   OU id.
909 * @param    int imgid  image id.
910 * @return   string     JSON string with image parameters
[5ff84a5]911 */
912$app->get('/ous/:ouid/images/:imgid(/)', 'validateApiKey',
[fb2ee20]913    function($ouid, $imgid) {
[5ff84a5]914        global $userid;
[fb2ee20]915        global $cmd;
916
917        $ouid = htmlspecialchars($ouid);
918        $imgid = htmlspecialchars($imgid);
[5ff84a5]919        // Database query.
920        $cmd->texto = <<<EOD
[9199fc7]921SELECT adm.idusuario, imagenes.*, nombreso AS os
[5ff84a5]922  FROM imagenes
923 RIGHT JOIN administradores_centros AS adm USING(idcentro)
[2154cbb]924  LEFT JOIN perfilessoft USING(idperfilsoft)
925  LEFT JOIN nombresos USING(idnombreso)
[9199fc7]926 WHERE adm.idusuario = '$userid'
[5ff84a5]927   AND adm.idcentro='$ouid'
928   AND idimagen='$imgid';
929EOD;
[fb2ee20]930        $rs=new Recordset;
931        $rs->Comando=&$cmd;
[5ff84a5]932        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]933        $rs->Primero();
[5ff84a5]934        // Check if user is an UO admin and repo exists.
[9199fc7]935        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["idimagen"])) {
[5ff84a5]936                // Read data.
[ffaf580]937                $response['id'] = (int)$rs->campos["idimagen"];
[bbc672f]938                $response['name'] = $rs->campos["nombreca"];
[fb2ee20]939                $response['description'] = $rs->campos["descripcion"];
940                $response['comments'] = $rs->campos["comentarios"];
[43f3bde]941                $response['inremotepc'] = ($rs->campos["inremotepc"] == 1);
[ffaf580]942                $response['repo']['id'] = (int)$rs->campos["idrepositorio"];
[fb2ee20]943                switch ($rs->campos["tipo"]) {
[5ff84a5]944                        // Image type.
[fb2ee20]945                        case 1:  $response['type'] = "monolithic"; break;
946                        case 2:  $response['type'] = "base"; break;
947                        case 3:  $response['type'] = "incremental";
948                                 $response['baseimg'] = $rs->campos["imagenid"];
949                                 $response['path'] = $rs->campos["ruta"];
950                                 break;
951                        default: $response['type'] = $rs->campos["tipo"];
952                }
953                if ($rs->campos["idordenador"] != 0) {
[5ff84a5]954                        // Source client data.
[ffaf580]955                        $response['client']['id'] = (int)$rs->campos["idordenador"];
956                        $response['client']['disk'] = (int)$rs->campos["numdisk"];
957                        $response['client']['partition'] = (int)$rs->campos["numpar"];
[fb2ee20]958                        $response['creationdate'] = $rs->campos["fechacreacion"];
[ffaf580]959                        $response['release'] = (int)$rs->campos["revision"];
[2154cbb]960                        $response['os'] = $rs->campos["os"];
[fb2ee20]961                }
962                jsonResponse(200, $response);
963        }
964        $rs->Cerrar();
965    }
966);
967
968// Lista de softeare instalado en una imagen.
[43f3bde]969/**
970 * @brief    List software installed in an image
971 * @note     Route: /ous/:ouid/images/:imgid/software, Method: GET
972 * @param    int ouid   OU id.
973 * @param    int imgid  image id.
974 * @return   string     JSON array with installed software
975 */$app->get('/ous/:ouid/images/:imgid/software(/)', 'validateApiKey',
[fb2ee20]976    function($ouid, $imgid) {
[5ff84a5]977        global $userid;
[fb2ee20]978        global $cmd;
979
980        $ouid = htmlspecialchars($ouid);
981        $imgid = htmlspecialchars($imgid);
[5ff84a5]982        // Database query.
[fb2ee20]983        $cmd->texto = <<<EOD
[9199fc7]984SELECT adm.idusuario, imagenes.idimagen, imagenes.nombreca,
[5ff84a5]985       nombresos.nombreso, softwares.descripcion
986  FROM imagenes
987 RIGHT JOIN administradores_centros AS adm USING(idcentro)
988  LEFT JOIN perfilessoft USING(idperfilsoft)
[bbc672f]989  LEFT JOIN nombresos USING(idnombreso)
[fb2ee20]990  LEFT JOIN perfilessoft_softwares USING(idperfilsoft)
991  LEFT JOIN softwares USING(idsoftware)
[9199fc7]992 WHERE adm.idusuario = '$userid'
[43f3bde]993   AND adm.idcentro='$ouid'
[5ff84a5]994   AND imagenes.idimagen='$imgid'
[fb2ee20]995 ORDER BY softwares.descripcion ASC;
996EOD;
997        $rs=new Recordset;
998        $rs->Comando=&$cmd;
[5ff84a5]999        if (!$rs->Abrir()) return(false);       // Error oppening recordset.
[fb2ee20]1000        $rs->Primero();
[5ff84a5]1001        // Check if user is an UO admin and repo exists.
[9199fc7]1002        if (checkAdmin($rs->campos["idusuario"]) and checkParameter($rs->campos["idimagen"])) {
[ffaf580]1003                $response['id'] = (int)$rs->campos["idimagen"];
[bbc672f]1004                $response['name'] = $rs->campos["nombreca"];
[5ff84a5]1005                if (is_null($rs->campos["nombreso"])) {
1006                        // Null object.
1007                        $response['software'] = Array();
1008                        jsonResponse(200, $response, JSON_FORCE_OBJECT);
1009                } else {
1010                        // Read data.
1011                        $response['software']['os'] = $rs->campos["nombreso"];
1012                        //$response['software']['type'] = ...;  // OS type
1013                        $response['software']['applications'] = Array();
1014                        while (!$rs->EOF) {
1015                                // Ignoring empty fields.
1016                                if (!is_null($rs->campos["descripcion"])) {
[57200ac]1017                                        array_push($response['software']['applications'], $rs->campos["descripcion"]);
[5ff84a5]1018                                }
[fb2ee20]1019                                $rs->Siguiente();
1020                        }
[5ff84a5]1021                        jsonResponse(200, $response);
[fb2ee20]1022                }
1023        }
1024        $rs->Cerrar();
1025    }
1026);
1027
Note: See TracBrowser for help on using the repository browser.