[4dabcbe] | 1 | <?php |
---|
| 2 | // ********************************************************************************************************* |
---|
| 3 | // Aplicación WEB: ogAdmWebCon |
---|
| 4 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla |
---|
| 5 | // Fecha Creaciónn: Año 2009-2010 |
---|
| 6 | // Fecha Última modificación: Agosto-2010 |
---|
| 7 | // Nombre del fichero: propiedades_repositorios.php |
---|
| 8 | // Descripción : |
---|
| 9 | // Presenta el formulario de captura de datos de un repositorio para insertar,modificar y eliminar |
---|
| 10 | // ********************************************************************************************************** |
---|
| 11 | include_once("../includes/ctrlacc.php"); |
---|
| 12 | include_once("../includes/opciones.php"); |
---|
| 13 | include_once("../includes/comunes.php"); |
---|
| 14 | include_once("../includes/CreaComando.php"); |
---|
| 15 | include_once("../clases/AdoPhp.php"); |
---|
| 16 | include_once("../idiomas/php/".$idioma."/propiedades_repositorios_".$idioma.".php"); |
---|
| 17 | // Fichero con funciones para trabajar con el webservice |
---|
| 18 | include_once("../includes/restfunctions.php"); |
---|
| 19 | //________________________________________________________________________________________________________ |
---|
| 20 | $opcion=0; |
---|
| 21 | $opciones=array($TbMsg[0],$TbMsg[1],$TbMsg[2],$TbMsg[3]); |
---|
| 22 | //________________________________________________________________________________________________________ |
---|
| 23 | $idrepositorio=0; |
---|
| 24 | $nombrerepositorio=""; |
---|
| 25 | $ip=""; |
---|
| 26 | $apiKeyRepo=""; |
---|
| 27 | $grupoid=0; |
---|
| 28 | $comentarios=""; |
---|
| 29 | $ordenadores=0; // Número de ordenador a los que da servicio |
---|
| 30 | $numordenadores=0; // Número de ordenador a los que da servicio |
---|
| 31 | |
---|
| 32 | if (isset($_GET["opcion"])) $opcion=$_GET["opcion"]; // Recoge parametros |
---|
| 33 | if (isset($_GET["idrepositorio"])) $idrepositorio=$_GET["idrepositorio"]; |
---|
| 34 | if (isset($_GET["grupoid"])) $grupoid=$_GET["grupoid"]; |
---|
| 35 | if (isset($_GET["identificador"])) $idrepositorio=$_GET["identificador"]; |
---|
| 36 | //________________________________________________________________________________________________________ |
---|
| 37 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando |
---|
| 38 | if (!$cmd) |
---|
| 39 | Header('Location: '.$pagerror.'?herror=2'); // Error de conexión con repositorio B.D. |
---|
| 40 | if ($opcion!=$op_alta){ |
---|
| 41 | $resul=TomaPropiedades($cmd,$idrepositorio); |
---|
| 42 | if (!$resul) |
---|
| 43 | Header('Location: '.$pagerror.'?herror=3'); // Error de recuperaci�n de datos. |
---|
| 44 | } |
---|
| 45 | //________________________________________________________________________________________________________ |
---|
| 46 | //######################################################################### |
---|
| 47 | |
---|
| 48 | // Si tenemos un apiKey podemos obtener la información desde el webservice en el repositorio |
---|
| 49 | if($apiKeyRepo != ""){ |
---|
| 50 | $repo[0]['url'] = "https://$ip/opengnsys/rest/repository/images"; |
---|
| 51 | $repo[0]['header'] = array('Authorization: '.$apiKeyRepo); |
---|
| 52 | $result = multiRequest($repo); |
---|
| 53 | if ($result[0]['code'] === 200) { |
---|
| 54 | $result = json_decode($result[0]['data']); |
---|
| 55 | $repodir = $result->directory; |
---|
| 56 | $totalrepo = humanSize($result->disk->total); |
---|
| 57 | $librerepo = humanSize($result->disk->free); |
---|
| 58 | $ocupadorepo = humanSize($result->disk->total - $result->disk->free); |
---|
| 59 | $porcentajerepo = 100 - floor(100 * $result->disk->free / $result->disk->total); |
---|
| 60 | $repoOus = $result->ous; |
---|
| 61 | $repoImages = $result->images; |
---|
| 62 | $repoWithApi = true; |
---|
| 63 | } else { |
---|
| 64 | // Error de acceso a la API REST. |
---|
| 65 | $repoWithApi = false; |
---|
| 66 | $repoImages = null; |
---|
| 67 | } |
---|
| 68 | } else { |
---|
| 69 | // Error de acceso a la API REST. |
---|
| 70 | $repoWithApi = false; |
---|
| 71 | $repoImages = null; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | //######################################################################### |
---|
| 75 | ?> |
---|
| 76 | <HTML> |
---|
| 77 | <HEAD> |
---|
[b0d5fb32] | 78 | <TITLE>Administración web de aulas</TITLE> |
---|
[4dabcbe] | 79 | <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
| 80 | <LINK rel="stylesheet" type="text/css" href="../estilos.css"> |
---|
| 81 | <SCRIPT language="javascript" src="../jscripts/validators.js"></SCRIPT> |
---|
| 82 | <SCRIPT language="javascript" src="../jscripts/propiedades_repositorios.js"></SCRIPT> |
---|
| 83 | <SCRIPT language="javascript" src="../jscripts/opciones.js"></SCRIPT> |
---|
| 84 | <?php echo '<SCRIPT language="javascript" src="../idiomas/javascripts/'.$idioma.'/propiedades_repositorios_'.$idioma.'.js"></SCRIPT>'?> |
---|
| 85 | </HEAD> |
---|
| 86 | <BODY> |
---|
| 87 | <DIV align=center> |
---|
| 88 | <FORM name="fdatos" action="../gestores/gestor_repositorios.php" method="post"> |
---|
| 89 | <INPUT type=hidden name=opcion value="<?php echo $opcion?>"> |
---|
| 90 | <INPUT type=hidden name=idrepositorio value="<?php echo $idrepositorio?>"> |
---|
| 91 | <INPUT type=hidden name=grupoid value="<?php echo $grupoid?>"> |
---|
| 92 | <INPUT type=hidden name=ordenadores value="<?php echo $ordenadores?>"> |
---|
| 93 | |
---|
| 94 | <P align=center class=cabeceras><?php echo $TbMsg[4]?><BR> |
---|
[b0d5fb32] | 95 | <SPAN class=subcabeceras><?php echo $opciones[$opcion]?></SPAN></P> |
---|
[4dabcbe] | 96 | <TABLE align=center border=0 cellPadding=1 cellSpacing=1 class=tabla_datos > |
---|
| 97 | <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> |
---|
| 98 | <TR> |
---|
[b0d5fb32] | 99 | <TH align="center"> <?php echo $TbMsg[5]?> </TH> |
---|
[4dabcbe] | 100 | <?php |
---|
| 101 | if ($opcion==$op_eliminacion) |
---|
| 102 | echo '<TD>'.$nombrerepositorio.'</TD>'; |
---|
| 103 | else |
---|
[b0d5fb32] | 104 | echo '<TD><INPUT class="formulariodatos" name="nombrerepositorio" style="width:200px" type="text" value="'.$nombrerepositorio.'"></TD>'; |
---|
[4dabcbe] | 105 | ?> |
---|
[b0d5fb32] | 106 | <TD valign="top" align="center" rowspan="4"> |
---|
[4dabcbe] | 107 | <IMG border="3" style="border-color:#63676b" src="../images/aula.jpg"> |
---|
[b0d5fb32] | 108 | <BR> Ordenadores: <?php echo $ordenadores?></TD> |
---|
[4dabcbe] | 109 | </TR> |
---|
| 110 | <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> |
---|
| 111 | <TR> |
---|
[b0d5fb32] | 112 | <TH align=center> <?php echo $TbMsg[6]?> </TH> |
---|
[4dabcbe] | 113 | <?php |
---|
| 114 | if ($opcion==$op_eliminacion) |
---|
| 115 | echo '<TD>'.$ip.'</TD>'; |
---|
| 116 | else |
---|
[b0d5fb32] | 117 | echo'<TD><INPUT class="formulariodatos" name="ip" type="text" style="width:200px" value="'.$ip.'"></TD>'; |
---|
[4dabcbe] | 118 | ?> |
---|
| 119 | </TR> |
---|
| 120 | <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> |
---|
| 121 | <TR> |
---|
[b0d5fb32] | 122 | <TH align=center> <?php echo $TbMsg[17]?> </TH> |
---|
[4dabcbe] | 123 | <?php |
---|
| 124 | if ($opcion==$op_eliminacion) |
---|
[6544149] | 125 | echo '<TD>********</TD>'; |
---|
[4dabcbe] | 126 | else |
---|
[b0d5fb32] | 127 | echo'<TD><INPUT class="formulariodatos" name="apiKeyRepo" type="text" style="width:200px" value="'.$apiKeyRepo.'"></TD>'; |
---|
[4dabcbe] | 128 | ?> |
---|
| 129 | </TR> |
---|
| 130 | <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> |
---|
| 131 | <TR> |
---|
[b0d5fb32] | 132 | <TH align=center> <?php echo $TbMsg[7]?> </TH> |
---|
[4dabcbe] | 133 | <?php |
---|
| 134 | if ($opcion==$op_eliminacion) |
---|
| 135 | echo '<TD colspan="2">'.$comentarios.'</TD>'; |
---|
| 136 | else |
---|
| 137 | echo '<TD colspan="2"><TEXTAREA class="formulariodatos" name="comentarios" rows=2 cols=50>'.$comentarios.'</TEXTAREA></TD>'; |
---|
| 138 | ?> |
---|
| 139 | </TR> |
---|
| 140 | |
---|
| 141 | <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> |
---|
| 142 | |
---|
| 143 | </TABLE> |
---|
| 144 | <?php if ( $opcion == 1 ){} else { ?> |
---|
| 145 | |
---|
| 146 | <TABLE align=center border=0 cellPadding=2 cellSpacing=2 class=tabla_datos > |
---|
| 147 | <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> |
---|
| 148 | |
---|
| 149 | <?php if ($repoWithApi) { ?> |
---|
| 150 | <TR> |
---|
[b0d5fb32] | 151 | <TH align=center width=125> <?php echo $TbMsg[11]?> </TH> |
---|
| 152 | <TH align=center width=120> <?php echo $TbMsg[12]?> </TH> |
---|
| 153 | <TH align=center width=120> <?php echo $TbMsg[13]?> </TH> |
---|
| 154 | <TH align=center width=101> <?php echo $TbMsg[14]?> </TH> |
---|
[4dabcbe] | 155 | </TR> |
---|
| 156 | <TR> |
---|
| 157 | <TD align=center width=125> <?php echo $totalrepo?> </TD> |
---|
| 158 | <TD align=center width=120> <?php echo $ocupadorepo?> </TD> |
---|
| 159 | <TD align=center width=120> <?php echo $librerepo?> </TD> |
---|
| 160 | <TD align=center width=101> <?php echo "$porcentajerepo %" ?> </TD> |
---|
| 161 | </TR> |
---|
| 162 | <?php |
---|
| 163 | // Si tenemos informacion del repositorio remoto, mostramos las imagenes |
---|
| 164 | if($repoWithApi == true && is_array($repoImages)){ |
---|
| 165 | echo "<tr class='tabla_listados_sin'><th colspan='4'>".$TbMsg['MSG_CONTENT']." $repodir</th></tr>\n"; |
---|
| 166 | |
---|
| 167 | echo "<tr><td>".$TbMsg['MSG_IMAGE']." (".$TbMsg['MSG_TYPE'].")</td><td>".$TbMsg['MSG_SIZE']."</td><td>".$TbMsg['MSG_MODIFIED']."</td><td>".$TbMsg['MSG_PERMISSIONS']."</td></tr>\n"; |
---|
| 168 | foreach($repoImages as $image){ |
---|
| 169 | echo "<tr class='tabla_listados_sin'>"; |
---|
| 170 | echo "<td>".$image->name." (".$image->type.")</td>"; |
---|
| 171 | echo "<td>".humanSize($image->size)."</td>"; |
---|
| 172 | echo "<td>".$image->modified."</td>"; |
---|
| 173 | echo "<td>".$image->mode."</td>"; |
---|
| 174 | echo "</tr>\n"; |
---|
| 175 | } |
---|
| 176 | foreach($repoOus as $ou) { |
---|
| 177 | foreach($ou->images as $image) { |
---|
| 178 | echo "<tr class='tabla_listados_sin'>"; |
---|
| 179 | echo "<td>".$ou->subdir." / ".$image->name." (".$image->type.")</td>"; |
---|
| 180 | echo "<td>".$image->size." bytes</td>"; |
---|
| 181 | echo "<td>".$image->modified."</td>"; |
---|
| 182 | echo "<td>".$image->mode."</td>"; |
---|
| 183 | echo "</tr>\n"; |
---|
| 184 | } |
---|
| 185 | } |
---|
| 186 | } |
---|
| 187 | ?> |
---|
| 188 | <?php }else { ?> |
---|
| 189 | <tr> |
---|
| 190 | <th align="center"> <?php echo '<strong>'.$TbMsg[15].'</strong></br>'.$TbMsg[16] ?></th> |
---|
| 191 | </tr> |
---|
| 192 | <?php } ?> |
---|
| 193 | <?php } ?> |
---|
| 194 | <!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> |
---|
| 195 | |
---|
| 196 | </TABLE> |
---|
| 197 | </FORM> |
---|
| 198 | </DIV> |
---|
| 199 | <?php |
---|
| 200 | //________________________________________________________________________________________________________ |
---|
| 201 | include_once("../includes/opcionesbotonesop.php"); |
---|
| 202 | //________________________________________________________________________________________________________ |
---|
| 203 | ?> |
---|
| 204 | </BODY> |
---|
| 205 | </HTML> |
---|
| 206 | <?php |
---|
| 207 | //________________________________________________________________________________________________________ |
---|
| 208 | // Recupera los datos de un repositorio |
---|
| 209 | // Parametros: |
---|
| 210 | // - cmd: Una comando ya operativo (con conexión abierta) |
---|
| 211 | // - id: El identificador del repositorio |
---|
| 212 | //________________________________________________________________________________________________________ |
---|
| 213 | function TomaPropiedades($cmd,$id){ |
---|
| 214 | global $nombrerepositorio; |
---|
| 215 | global $ip; |
---|
| 216 | global $comentarios; |
---|
| 217 | global $apiKeyRepo; |
---|
| 218 | global $ordenadores; |
---|
| 219 | |
---|
| 220 | $cmd->texto=<<<EOT |
---|
[b3dfeb6] | 221 | SELECT repositorios.*, COUNT(ordenadores.idordenador) AS numordenadores |
---|
[4dabcbe] | 222 | FROM repositorios |
---|
[6449e04] | 223 | LEFT JOIN ordenadores USING(idrepositorio) |
---|
[4dabcbe] | 224 | WHERE repositorios.idrepositorio='$id'; |
---|
| 225 | EOT; |
---|
| 226 | $rs=new Recordset; |
---|
| 227 | $rs->Comando=&$cmd; |
---|
| 228 | if (!$rs->Abrir()) return(true); // Error al abrir recordset |
---|
| 229 | $rs->Primero(); |
---|
| 230 | if (!$rs->EOF){ |
---|
| 231 | $nombrerepositorio=$rs->campos["nombrerepositorio"]; |
---|
| 232 | $ip=$rs->campos["ip"]; |
---|
| 233 | $comentarios=$rs->campos["comentarios"]; |
---|
| 234 | $apiKeyRepo=$rs->campos["apikey"]; |
---|
| 235 | $ordenadores=$rs->campos["numordenadores"]; |
---|
| 236 | } |
---|
| 237 | $rs->Cerrar(); |
---|
| 238 | return(true); |
---|
| 239 | } |
---|