1 | <?php |
---|
2 | // ************************************************************************************************************************************************* |
---|
3 | // Aplicación WEB: ogAdmWebCon |
---|
4 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla |
---|
5 | // Fecha Creación: Año 2009-2010 |
---|
6 | // Fecha Última modificación: Agosto-2010 |
---|
7 | // Nombre del fichero: configuraciones.php |
---|
8 | // Descripción : |
---|
9 | // Muestra la configuración de las particiones de los ordenadores de un aula |
---|
10 | // ************************************************************************************************************************************************* |
---|
11 | include_once("../includes/ctrlacc.php"); |
---|
12 | include_once("../clases/AdoPhp.php"); |
---|
13 | include_once("../includes/CreaComando.php"); |
---|
14 | include_once("../includes/comunes.php"); |
---|
15 | include_once("../includes/constantes.php"); |
---|
16 | include_once("../idiomas/php/".$idioma."/configuraciones_".$idioma.".php"); |
---|
17 | include_once("../includes/ConfiguracionesParticiones.php"); |
---|
18 | |
---|
19 | define("LOG_FILE", "/opt/opengnsys/log/ogagent.log"); |
---|
20 | |
---|
21 | //________________________________________________________________________________________________________ |
---|
22 | // |
---|
23 | // Captura parámetros |
---|
24 | //________________________________________________________________________________________________________ |
---|
25 | |
---|
26 | $ambito=0; |
---|
27 | $idambito=0; |
---|
28 | $swp=0; // Switch que indica si viene de las propiedades de ordenadores |
---|
29 | // Agrupamiento por defecto |
---|
30 | $fk_sysFi=0; |
---|
31 | $fk_nombreSO=0; |
---|
32 | $fk_tamano=0; |
---|
33 | $fk_imagen=0; |
---|
34 | $fk_perfil=0; |
---|
35 | $fk_cache=0; |
---|
36 | |
---|
37 | if (isset($_GET["idambito"])) $idambito=$_GET["idambito"]; |
---|
38 | if (isset($_GET["ambito"])) $ambito=$_GET["ambito"]; |
---|
39 | if (isset($_GET["swp"])) $swp=$_GET["swp"]; |
---|
40 | |
---|
41 | if (isset($_POST["idambito"])) $idambito=$_POST["idambito"]; |
---|
42 | if (isset($_POST["ambito"])) $ambito=$_POST["ambito"]; |
---|
43 | |
---|
44 | if (isset($_POST["fk_sysFi"])) $fk_sysFi=$_POST["fk_sysFi"]; |
---|
45 | if (isset($_POST["fk_nombreSO"])) $fk_nombreSO=$_POST["fk_nombreSO"]; |
---|
46 | if (isset($_POST["fk_tamano"])) $fk_tamano=$_POST["fk_tamano"]; |
---|
47 | if (isset($_POST["fk_imagen"])) $fk_imagen=$_POST["fk_imagen"]; |
---|
48 | if (isset($_POST["fk_perfil"])) $fk_perfil=$_POST["fk_perfil"]; |
---|
49 | if (isset($_POST["fk_cache"])) $fk_cache=$_POST["fk_cache"]; |
---|
50 | |
---|
51 | //________________________________________________________________________________________________________ |
---|
52 | |
---|
53 | $cmd=CreaComando($cadenaconexion); |
---|
54 | if (!$cmd) |
---|
55 | Header('Location: '.$pagerror.'?herror=2'); // Error de conexión con servidor B.D. |
---|
56 | //________________________________________________________________________________________________________ |
---|
57 | ?> |
---|
58 | <html lang="es"> |
---|
59 | <head> |
---|
60 | <title>Administración web de aulas</title> |
---|
61 | <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
62 | <link rel="stylesheet" type="text/css" href="../estilos.css"> |
---|
63 | </head> |
---|
64 | <body> |
---|
65 | <?php |
---|
66 | switch($ambito){ |
---|
67 | case $AMBITO_AULAS : |
---|
68 | $urlimg='../images/iconos/aula.gif'; |
---|
69 | $textambito=$TbMsg[2]; |
---|
70 | break; |
---|
71 | case $AMBITO_GRUPOSORDENADORES : |
---|
72 | $urlimg='../images/iconos/carpeta.gif'; |
---|
73 | $textambito=$TbMsg[3]; |
---|
74 | break; |
---|
75 | case $AMBITO_ORDENADORES : |
---|
76 | $urlimg='../images/iconos/ordenador.gif'; |
---|
77 | $textambito=$TbMsg[4]; |
---|
78 | } |
---|
79 | if(!$swp){ |
---|
80 | echo '<p align=center><span class=cabeceras>'.$TbMsg[0].' </span><br>'; |
---|
81 | echo '<IMG src="'.$urlimg.'"> <span align=center class=subcabeceras><U>'.$TbMsg[1].' |
---|
82 | : '.$textambito.'</U></span> </span></p>'; |
---|
83 | } |
---|
84 | |
---|
85 | switch($ambito){ |
---|
86 | case $AMBITO_AULAS : |
---|
87 | $resul=datosAulas($cmd,$idambito); |
---|
88 | break; |
---|
89 | case $AMBITO_GRUPOSORDENADORES : |
---|
90 | $resul=datosGruposOrdenadores($cmd,$idambito); |
---|
91 | break; |
---|
92 | case $AMBITO_ORDENADORES : |
---|
93 | if(!$swp) |
---|
94 | $resul=datosOrdenadores($cmd,$idambito); |
---|
95 | break; |
---|
96 | } |
---|
97 | if($ambito!=$AMBITO_ORDENADORES){ |
---|
98 | ?> |
---|
99 | <P align=center><SPAN align=center class=subcabeceras><?php echo $TbMsg[19]?></SPAN></P> |
---|
100 | <FORM action="configuraciones.php" name="fdatos" method="POST"> |
---|
101 | <INPUT type="hidden" name="idambito" value="<?php echo $idambito?>"> |
---|
102 | <INPUT type="hidden" name="ambito" value="<?php echo $ambito?>"> |
---|
103 | <TABLE class="tabla_busquedas" align=center border=0 cellPadding=0 cellSpacing=0> |
---|
104 | <TR> |
---|
105 | <TH height=15 align="center" colspan=17><?php echo $TbMsg[18]?></TH> |
---|
106 | </TR> |
---|
107 | <TR> |
---|
108 | |
---|
109 | <TD align=right><?php echo $TbMsg[30]?></TD> |
---|
110 | <TD align=center><INPUT type="checkbox" value="<?php echo $msk_sysFi?>" name="fk_sysFi" <?php if($fk_sysFi==$msk_sysFi) echo " checked "?>></TD> |
---|
111 | <TD width="20" align=center> </TD> |
---|
112 | <TD align=right><?php echo $TbMsg[31]?></TD> |
---|
113 | <TD align=center><INPUT type="checkbox" value="<?php echo $msk_nombreSO?>" name="fk_nombreSO" <?php if($fk_nombreSO==$msk_nombreSO) echo " checked "?>></TD> |
---|
114 | <TD width="20" align=center> </TD> |
---|
115 | <TD align=right><?php echo $TbMsg[32]?></TD> |
---|
116 | <TD align=center><INPUT type="checkbox" value="<?php echo $msk_tamano?>" name="fk_tamano" <?php if($fk_tamano==$msk_tamano) echo " checked "?>></TD> |
---|
117 | <TD width="20" align=center> </TD> |
---|
118 | <TD align=right><?php echo $TbMsg[33]?></TD> |
---|
119 | <TD align=center><INPUT type="checkbox" value="<?php echo $msk_imagen?>" name="fk_imagen" <?php if($fk_imagen==$msk_imagen) echo " checked "?>></TD> |
---|
120 | <TD width="20" align=center> </TD> |
---|
121 | <TD align=right><?php echo $TbMsg[34]?></TD> |
---|
122 | <TD align=center><INPUT type="checkbox" value="<?php echo $msk_perfil?>" name="fk_perfil" <?php if($fk_perfil==$msk_perfil) echo " checked "?>></TD> |
---|
123 | <TD width="20" align=center> </TD> |
---|
124 | <TD align=right><?php echo $TbMsg[495]?></TD> |
---|
125 | <TD align=center><INPUT type="checkbox" value="<?php echo $msk_cache?>" name="fk_cache" <?php if($fk_cache==$msk_cache) echo " checked "?>></TD> |
---|
126 | |
---|
127 | |
---|
128 | </TR> |
---|
129 | <TR> |
---|
130 | <TD height=2 style="BORDER-TOP:#999999 1px solid;" align="center" colspan=17> </TD> |
---|
131 | </TR> |
---|
132 | <TR> |
---|
133 | <TD height=20 align="center" colspan=14> |
---|
134 | <A href=#> |
---|
135 | <IMG border=0 src="../images/boton_confirmar.gif" onClick="document.fdatos.submit()"></A></TD> |
---|
136 | </TR> |
---|
137 | </TABLE> |
---|
138 | </FORM> |
---|
139 | <?php |
---|
140 | } |
---|
141 | $sws=$fk_sysFi | $fk_nombreSO | $fk_tamano | $fk_imagen | $fk_perfil | $fk_cache; |
---|
142 | pintaConfiguraciones($cmd,$idambito,$ambito,9,$sws,false); |
---|
143 | if ($ambito == $AMBITO_ORDENADORES) { |
---|
144 | datos_sesiones($cmd, $idambito); |
---|
145 | } |
---|
146 | ?> |
---|
147 | </body> |
---|
148 | </html> |
---|
149 | |
---|
150 | <?php |
---|
151 | //________________________________________________________________________________________________________ |
---|
152 | function datosAulas($cmd,$idaula) |
---|
153 | { |
---|
154 | global $TbMsg; |
---|
155 | |
---|
156 | $cmd->texto="SELECT DISTINCT aulas.*, COUNT(ordenadores.idordenador) AS numordenadores |
---|
157 | FROM aulas |
---|
158 | LEFT JOIN ordenadores ON ordenadores.idaula=aulas.idaula |
---|
159 | WHERE aulas.idaula=$idaula"; |
---|
160 | $rs=new Recordset; |
---|
161 | $rs->Comando=&$cmd; |
---|
162 | if ($rs->Abrir()){ |
---|
163 | $rs->Primero(); |
---|
164 | if (!$rs->EOF){ |
---|
165 | $nombreaula=$rs->campos["nombreaula"]; |
---|
166 | $urlfoto=$rs->campos["urlfoto"]; |
---|
167 | $cagnon=$rs->campos["cagnon"]; |
---|
168 | $pizarra=$rs->campos["pizarra"]; |
---|
169 | $ubicacion=$rs->campos["ubicacion"]; |
---|
170 | $comentarios=$rs->campos["comentarios"]; |
---|
171 | $puestos=$rs->campos["puestos"]; |
---|
172 | $ordenadores=$rs->campos["numordenadores"]; |
---|
173 | } |
---|
174 | $rs->Cerrar(); |
---|
175 | } |
---|
176 | ?> |
---|
177 | <TABLE align=center border=0 cellPadding=1 cellSpacing=1 class=tabla_datos> |
---|
178 | <TR> |
---|
179 | <TH align=center> <?php echo $TbMsg[5]?> </TD> |
---|
180 | <?php |
---|
181 | echo '<TD>'. $nombreaula.'</TD>'; |
---|
182 | echo '<TH align=center> '.$TbMsg[7].' </TH>'; |
---|
183 | echo '<TD><INPUT class="formulariodatos" name=cagnon type=checkbox '; |
---|
184 | if ($cagnon) echo ' checked '; |
---|
185 | echo '></TD>'; |
---|
186 | ?> |
---|
187 | <TD valign=top align=center rowspan=3> |
---|
188 | <IMG border=3 style="border-color:#63676b" |
---|
189 | src="<?php echo "../images/fotos/".$urlfoto?>"> |
---|
190 | <BR><center> <?php echo $TbMsg[13].': '. $ordenadores?></center></TD> |
---|
191 | </TR> |
---|
192 | <TR> |
---|
193 | <TH align=center> <?php echo $TbMsg[6]?> </TH> |
---|
194 | <?php |
---|
195 | echo '<TD>'.$ubicacion.'</TD>'; |
---|
196 | ?> |
---|
197 | <TH align=center> <?php echo $TbMsg[8]?> </TD> |
---|
198 | <?php |
---|
199 | echo '<TD><INPUT class="formulariodatos" name=pizarra type=checkbox '; |
---|
200 | if ($pizarra) echo ' checked '; |
---|
201 | echo '></TD>'; |
---|
202 | ?> |
---|
203 | </TR> |
---|
204 | <TR> |
---|
205 | <TH align=center ><?php echo $TbMsg[9]?> </TD> |
---|
206 | <?php |
---|
207 | echo '<TD>'.$puestos.'</TD>'; |
---|
208 | ?> |
---|
209 | <TH align=center> <?php echo $TbMsg[12]?> </TD> |
---|
210 | <?php |
---|
211 | echo '<TD>'.$comentarios.'</TD>'; |
---|
212 | ?> |
---|
213 | </TR> |
---|
214 | </TABLE> |
---|
215 | <?php |
---|
216 | } |
---|
217 | //________________________________________________________________________________________________________ |
---|
218 | function datosOrdenadores($cmd,$idordenador) |
---|
219 | { |
---|
220 | global $TbMsg; |
---|
221 | |
---|
222 | $cmd->texto="SELECT nombreordenador, ip, mac, fotoord, perfileshard.descripcion AS perfilhard |
---|
223 | FROM ordenadores |
---|
224 | LEFT JOIN perfileshard ON perfileshard.idperfilhard=ordenadores.idperfilhard |
---|
225 | WHERE ordenadores.idordenador=$idordenador"; |
---|
226 | $rs=new Recordset; |
---|
227 | $rs->Comando=&$cmd; |
---|
228 | if ($rs->Abrir()){ |
---|
229 | $rs->Primero(); |
---|
230 | if (!$rs->EOF){ |
---|
231 | $nombreordenador=$rs->campos["nombreordenador"]; |
---|
232 | $ip=$rs->campos["ip"]; |
---|
233 | $mac=$rs->campos["mac"]; |
---|
234 | $fotoordenador=$rs->campos["fotoord"]; |
---|
235 | $perfilhard=$rs->campos["perfilhard"]; |
---|
236 | } |
---|
237 | $rs->Cerrar(); |
---|
238 | } |
---|
239 | ?> |
---|
240 | <TABLE align=center border=0 cellPadding=1 cellSpacing=1 class=tabla_datos> |
---|
241 | <TR> |
---|
242 | <TH align=center> <?php echo $TbMsg[14]?> </TD> |
---|
243 | <TD><?php echo $nombreordenador;?></TD> |
---|
244 | <TD colspan=2 valign=top align=left rowspan=4><IMG border=2 style="border-color:#63676b" |
---|
245 | src="<?php if ($fotoordenador==""){echo "../images/fotos/fotoordenador.gif";} |
---|
246 | else{echo "../images/fotos/".$fotoordenador;}?>"> |
---|
247 | </TD> |
---|
248 | |
---|
249 | </TR> |
---|
250 | <TR> |
---|
251 | <TH align=center> <?php echo $TbMsg[15]?> </TD> |
---|
252 | <?php echo '<TD>'.$ip.'</TD>';?> |
---|
253 | </TR> |
---|
254 | <TR> |
---|
255 | <TH align=center> <?php echo $TbMsg[16]?> </TD> |
---|
256 | <?php echo '<TD>'.$mac.'</TD>';?> |
---|
257 | </TR> |
---|
258 | <TR> |
---|
259 | <TH align=center> <?php echo $TbMsg[17]?> </TD> |
---|
260 | <?php echo '<TD>'.$perfilhard.'</TD>';?> |
---|
261 | </TR> |
---|
262 | <TR> |
---|
263 | </TABLE> |
---|
264 | <?php |
---|
265 | } |
---|
266 | ?> |
---|
267 | <?php |
---|
268 | //________________________________________________________________________________________________________ |
---|
269 | function datosGruposOrdenadores($cmd,$idgrupo) |
---|
270 | { |
---|
271 | global $TbMsg; |
---|
272 | |
---|
273 | $cmd->texto="SELECT DISTINCT gruposordenadores.*, COUNT(*) AS numordenadores |
---|
274 | FROM gruposordenadores |
---|
275 | INNER JOIN ordenadores ON ordenadores.grupoid=gruposordenadores.idgrupo |
---|
276 | WHERE gruposordenadores.idgrupo=$idgrupo"; |
---|
277 | $rs=new Recordset; |
---|
278 | $rs->Comando=&$cmd; |
---|
279 | if ($rs->Abrir()){ |
---|
280 | $rs->Primero(); |
---|
281 | if (!$rs->EOF){ |
---|
282 | $nombregrupoordenador=$rs->campos["nombregrupoordenador"]; |
---|
283 | $ordenadores=$rs->campos["numordenadores"]; |
---|
284 | $idaula=$rs->campos["idaula"]; |
---|
285 | } |
---|
286 | $rs->Cerrar(); |
---|
287 | } |
---|
288 | if ($ordenadores==0) |
---|
289 | { |
---|
290 | $cmd->texto="SELECT *, COUNT(*) AS numordenadores |
---|
291 | FROM gruposordenadores |
---|
292 | WHERE idgrupo=".$idgrupo; |
---|
293 | $rs=new Recordset; |
---|
294 | $rs->Comando=&$cmd; |
---|
295 | if ($rs->Abrir()){ |
---|
296 | $rs->Primero(); |
---|
297 | if (!$rs->EOF){ |
---|
298 | $nombregrupoordenador=$rs->campos["nombregrupoordenador"]; |
---|
299 | $ordenadores=$rs->campos["numordenadores"]; |
---|
300 | $idaula=$rs->campos["idaula"]; |
---|
301 | } |
---|
302 | $rs->Cerrar(); |
---|
303 | } |
---|
304 | } |
---|
305 | ////////////////////////////////////// |
---|
306 | $cmd->texto="SELECT DISTINCT aulas.*,count(*) as numordenadores |
---|
307 | FROM aulas |
---|
308 | INNER JOIN ordenadores ON ordenadores.idaula=aulas.idaula |
---|
309 | WHERE aulas.idaula=".$idaula; |
---|
310 | |
---|
311 | $rs=new Recordset; |
---|
312 | $rs->Comando=&$cmd; |
---|
313 | if ($rs->Abrir()){ |
---|
314 | $rs->Primero(); |
---|
315 | if (!$rs->EOF){ |
---|
316 | $urlfoto=$rs->campos["urlfoto"]; |
---|
317 | $nombreaula=$rs->campos["nombreaula"]; |
---|
318 | } |
---|
319 | $rs->Cerrar(); |
---|
320 | } |
---|
321 | ?> |
---|
322 | <TABLE align=center border=0 cellPadding=1 cellSpacing=1 class=tabla_datos> |
---|
323 | <TR> |
---|
324 | <TH align=center> <?php echo $TbMsg[5].'</br>'.$nombreaula?> </TD> |
---|
325 | <?php |
---|
326 | echo '<TD>'.$nombregrupoordenador.'</TD> |
---|
327 | <TD colspan=2 valign=top align=center rowspan=2> |
---|
328 | <IMG border=3 style="border-color:#63676b" src="../images/fotos/'.$urlfoto.'"><br> |
---|
329 | <center> '.$TbMsg[13].': '. $ordenadores.'</center> |
---|
330 | </TD>'; |
---|
331 | |
---|
332 | ?> |
---|
333 | </TR> |
---|
334 | </TABLE> |
---|
335 | <?php |
---|
336 | } |
---|
337 | |
---|
338 | /** |
---|
339 | * @param object $cmd |
---|
340 | * @param int $idordenador |
---|
341 | */ |
---|
342 | function datos_sesiones($cmd, $idordenador) |
---|
343 | { |
---|
344 | global $TbMsg; |
---|
345 | $os_color = ['Windows' => "blue", 'Linux' => "magenta", 'MacOS' => "orange"]; |
---|
346 | $html = ""; |
---|
347 | $ip = ""; |
---|
348 | |
---|
349 | $cmd->texto = "SELECT ip FROM ordenadores WHERE idordenador = $idordenador"; |
---|
350 | $rs = new Recordset; |
---|
351 | $rs->Comando=&$cmd; |
---|
352 | if ($rs->Abrir()){ |
---|
353 | $rs->Primero(); |
---|
354 | $ip = $rs->campos["ip"]; |
---|
355 | $rs->Cerrar(); |
---|
356 | } |
---|
357 | if ($ip) { |
---|
358 | foreach (file(LOG_FILE) as $line) { |
---|
359 | if (strstr($line, "ip=$ip")) { |
---|
360 | $fields = preg_split("/[:,=]/", rtrim($line, ". \t\n\r\0\x0B")); |
---|
361 | $date_time = str_replace("T", " ", $fields[0]) . ":" . $fields[1] . ":" . |
---|
362 | preg_replace("/\+.*$/", "", $fields[2]); |
---|
363 | $operation = trim($fields[3]); |
---|
364 | $username = $os_type = $os_version = ""; |
---|
365 | switch ($operation) { |
---|
366 | case "OGAgent started": |
---|
367 | $operation = "Iniciar"; |
---|
368 | $os_type = $fields[14] ?? ""; |
---|
369 | $os_version = trim($fields[15] ?? ""); |
---|
370 | break; |
---|
371 | case "OGAgent stopped": |
---|
372 | $operation = "Apagar"; |
---|
373 | $os_type = $fields[14] ?? ""; |
---|
374 | $os_version = trim($fields[15] ?? ""); |
---|
375 | break; |
---|
376 | case "User logged in": |
---|
377 | $operation = "Entrar"; |
---|
378 | $username = $fields[7] ?? ""; |
---|
379 | $os_type = $fields[11] ?? ""; |
---|
380 | $os_version = trim($fields[12] ?? ""); |
---|
381 | break; |
---|
382 | case "User logged out": |
---|
383 | $operation = "Salir"; |
---|
384 | $username = $fields[7] ?? "-"; |
---|
385 | break; |
---|
386 | default: |
---|
387 | $operation = "ERROR"; |
---|
388 | } |
---|
389 | $color = $os_color[$os_type] ?? ""; |
---|
390 | $html .= <<<EOT |
---|
391 | <tr> |
---|
392 | <td>$date_time</td> |
---|
393 | <td>$operation</td> |
---|
394 | <td style="background-color: $color; color: white;">$os_version</td> |
---|
395 | <td>$username</td> |
---|
396 | </tr> |
---|
397 | EOT; |
---|
398 | } |
---|
399 | } |
---|
400 | if (!empty($html)) { |
---|
401 | echo <<<EOT |
---|
402 | <table class="tabla_datos" style="margin-left: auto; margin-right: auto;"> |
---|
403 | <tr> |
---|
404 | <th colspan="5">${TbMsg["SECT_SESSIONS"]}</th> |
---|
405 | </tr> |
---|
406 | <tr> |
---|
407 | <th>${TbMsg["SESS_DATETIME"]}</th> |
---|
408 | <th>${TbMsg["SESS_OPERATION"]}</th> |
---|
409 | <th>${TbMsg["SESS_OPSYS"]}</th> |
---|
410 | <th>${TbMsg["SESS_USER"]}</th> |
---|
411 | </tr> |
---|
412 | $html |
---|
413 | </table> |
---|
414 | EOT; |
---|
415 | } else { |
---|
416 | echo <<<EOT |
---|
417 | <table class="tabla_datos" style="margin-left: auto; margin-right: auto;"> |
---|
418 | <tr> |
---|
419 | <th>${TbMsg["SESS_NOSESSIONS"]}</th> |
---|
420 | </tr> |
---|
421 | </table> |
---|
422 | EOT; |
---|
423 | } |
---|
424 | } |
---|
425 | } |
---|
426 | |
---|