source: admin/WebConsole/principal/boot_grub4dos_crear.php @ ed4b2fe

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacion
Last change on this file since ed4b2fe was ee0a327, checked in by Irina Gómez <irinagomez@…>, 6 years ago

#802 #888 Fix error in 8c88e08: NetbootAvanzado? UEFI compatibility

  • Property mode set to 100644
File size: 18.4 KB
Line 
1<?php
2include_once("../includes/ctrlacc.php");
3include_once("../clases/AdoPhp.php");
4include_once("../includes/CreaComando.php");
5include_once("../idiomas/php/".$idioma."/boot_grub4dos_".$idioma.".php");
6
7$cmd=CreaComando($cadenaconexion);
8if (!$cmd)
9        Header('Location: '.$pagerror.'?herror=2'); // Error de conexión con servidor B.D.
10//________________________________________________________________________________________________________
11
12if (isset($_POST["litambito"])) $litambito=$_POST["litambito"]; // Recoge parametros
13if (isset($_POST["idambito"])) $idambito=$_POST["idambito"];
14if (isset($_POST["nombreambito"])) $nombreambito=$_POST["nombreambito"];
15if (isset($_POST["opcion"])) $opcion=$_POST["opcion"];
16if (isset($_POST["opcioncrear"])) $opcioncrear=$_POST["opcioncrear"];
17$boton = isset ($_REQUEST["boton"]) ? $_REQUEST["boton"] : "";
18$confirmado = ($boton == $TbMsg[13] && ($opcioncrear == "crear" || $opcioncrear == "modificar")) ? "1" : "";
19$guarnomb = isset($_POST["nombrenuevoboot"]) ? ucfirst($_POST["nombrenuevoboot"]) : "";
20$admin = isset($_POST["modo"]) ? $_POST["modo"] : "";
21$selectfile = isset($_POST["selectfile"]) ? $_POST["selectfile"] : "";
22$boottype = isset($_POST["boottype"]) ? $_POST["boottype"] : "";
23$dirtemplates= ( $boottype === "uefi" ) ? "/var/lib/tftpboot/grub/templates/"  : "/var/lib/tftpboot/menu.lst/templates/";
24$descripcion = "";
25$modo = "";
26?>
27
28<html>
29<head>
30<TITLE>Administración web de aulas</TITLE>
31
32<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
33        <LINK rel="stylesheet" type="text/css" href="../estilos.css">
34        <SCRIPT language="javascript" src="../jscripts/propiedades_aulas.js"></SCRIPT>
35        <SCRIPT language="javascript" src="../jscripts/opciones.js"></SCRIPT>
36        <SCRIPT language="javascript" src="../jscripts/boot_grub4dos.js"></SCRIPT>
37        <SCRIPT language="javascript" src="../idiomas/javascripts/esp/propiedades_aulas_esp.js"></SCRIPT>
38</head>
39
40<body>
41<P align=center class=cabeceras><?php echo $TbMsg[42]; ?><BR>
42        <SPAN align=center class=subcabeceras> <?php echo $nombreambito; ?> </SPAN></P>
43<?php
44//##################################################################################################################################
45//###########  NUEVO COLUMNA ARRANQUE  #############################################################################################
46//##################################################################################################################################
47
48if ($opcioncrear == "crear")
49        {
50        //$confirmado=$_POST["confirmado"];
51        if ($confirmado == 1)
52                {       
53                                $descripfich=$guarnomb;$descripfich=preg_replace("/[^A-Za-z0-9]/", "-", $descripfich);
54                                $guarnomb=preg_replace("/[^A-Za-z0-9]/", "", $descripfich);
55
56
57                        if($guarnomb === "") {
58                                $action="./boot_grub4dos_crear.php";
59                                $mensaje="<br><br><SPAN align=center class=subcabeceras>".$TbMsg[14]."</span>";
60
61                        } else {
62
63                                // ultimo número: a todos los números posibles le quito los ya usados
64                                //     y me quedo con el primero
65                                chdir($dirtemplates);
66                                $pn=array_map("principio",glob("*"));
67                                $todos=range(21,99);
68                                $ultimonumero=current(array_diff($todos,$pn));
69
70                                $nombrenuevoboot=$ultimonumero.$guarnomb;
71                                $parametrosnuevoboot=$_POST["parametrosnuevoboot"];
72                                $nuevoboot = $dirtemplates.$nombrenuevoboot;
73
74                                $fp = fopen($nuevoboot, "w");
75                                $string = $TbMsg[22].$descripfich."\n".$parametrosnuevoboot;
76                                $write = fputs($fp, $string);
77                                fclose($fp);
78
79                                $action="./boot_grub4dos.php";
80                                $mensaje=$TbMsg[6]."<br><br><SPAN align=center class=subcabeceras>".$descripfich."</span>";
81                        }
82                        ?>
83                                                <form name="crearranque" method="post" action="<?php echo $action ?>">
84                                                <input type="hidden" name="confirmado" value="">
85                                                <input type="hidden" name="ultimonumero" value="<?php echo $ultimonumero?>">
86                                                <input type="hidden" name="litambito" value="<?php echo $litambito?>">
87                                                <input type="hidden" name="idambito" value="<?php echo $idambito?>">
88                                                <input type="hidden" name="nombreambito" value="<?php echo $nombreambito?>">
89                                                <input type="hidden" name="opcioncrear" value="crear">
90                                                <input type="hidden" name="boottype" value="<?php echo $boottype ?>">
91                                                <TABLE width="500" align=center border=1 >
92                                                <TR><TD align="center"><br><?php echo $mensaje;?></span><br><br><br>   
93                                                <input type="submit" value="Continuar" name="nuevoarran">
94                                                </TD></TR>
95                                                </TABLE>
96                                                </form>
97<?php }else{
98?>
99
100<form name="crearranque" method="post" action="./boot_grub4dos_crear.php">
101<input type="hidden" name="litambito" value="<?php echo $litambito?>">
102<input type="hidden" name="idambito" value="<?php echo $idambito?>">
103<input type="hidden" name="nombreambito" value="<?php echo $nombreambito?>">
104<input type="hidden" name="boottype" value="<?php echo $boottype ?>">
105<input type="hidden" name="opcioncrear" value="crear">
106<input type="hidden" name="modo" value="1">
107
108<TABLE width="650" align=CENTER border=1 cellPadding=1 cellSpacing=1 class=tabla_datos >
109
110<TR align=center>
111        <TD height="70" colspan="2" valign="middle">
112                <SPAN align=center class=cabeceras> <?php echo $TbMsg[3]?> </SPAN>
113        </TD>
114  </TR>
115<TR align=right>
116        <TD colspan="2" valign="middle">
117
118
119
120        </TD>
121  </TR>
122<TR>
123        <TD width="150" height="10" valign="middle">
124                <SPAN align=center class=subcabeceras><?php echo $TbMsg[12]." ($boottype)"?></SPAN>
125        </TD>
126
127        <TD width="500" height="10" valign="middle">
128                <input type="text" name="nombrenuevoboot" id="textfield" size="25" value="<?php echo $guarnomb ?>">
129        </TD>
130
131</TR>
132<TR>
133        <TD width="150" height="100" valign="middle">
134
135<SPAN align=center class=subcabeceras><?php echo $TbMsg[19]?><br></SPAN>
136<?php
137// Boton utilizar plantilla o no.
138if ($boton == $TbMsg[17]) {
139        echo '<input name=boton type=submit value="'.$TbMsg[18].'">';
140}else{
141        echo '<input name=boton type=submit value="'.$TbMsg[17].'">';
142}
143?>
144        </TD>
145
146        <TD width="500" height="100" valign="middle">
147
148
149        <textarea name="parametrosnuevoboot" id="parametrosnuevoboot" cols="60" rows="12">
150<?php
151if ($boton == $TbMsg[17])
152echo "timeout 3
153title FirstHardDisk-FirstPartition
154keeppxe
155root (hd0,0)
156chainloader (hd0,0)+1
157boot";
158?>
159        </textarea>             
160        </TD>
161</TR>
162<TR>
163        <TD width="150"  valign="middle">
164
165                <input type="submit" name="boton" value="<?php echo $TbMsg[13]?>">
166        </TD>
167
168<TD width="500"  valign="middle">
169                <!-- Cancelar: vuelvo a página de netbootavanzado -->
170                <input type="submit" value="<?php echo $TbMsg[16]?>" onclick='document.forms[0].action="./boot_grub4dos.php";'>
171        </TD>
172</TR>
173</TABLE>
174</form>
175<?php
176//##################################################################################################################################
177//###########  NUEVO COLUMNA ARRANQUE  #############################################################################################
178//##################################################################################################################################
179}}?>
180
181
182<?php
183//##################################################################################################################################
184//###########  MODIFICAR COLUMNA ARRANQUE  #########################################################################################
185//##################################################################################################################################
186if ($opcioncrear == "modificar")
187        {
188        $action="./boot_grub4dos_crear.php";
189        $confirmado=isset($_POST["confirmado"]) ? $_POST["confirmado"] : "";
190        // Realizamos los cambios en el fichero
191        if ($confirmado == 1)
192                {
193                                $modificadescripcion=ucfirst($_POST["modificadescripcion"]);
194                                $descripfich=$modificadescripcion;$descripfich=preg_replace("/[^A-Za-z0-9]/", "-", $descripfich);
195                                $ficherow=$dirtemplates.$_POST["nombrefichero"];//echo $ficherow."<br>";
196                                $parametrosmodifica=$_POST["parametrosmodifica"];
197
198                                if(empty($modificadescripcion)) {
199                                        $mensaje=$TbMsg[14];
200                                }else{
201
202                                $fp = fopen($ficherow, "w");
203                                $string = $TbMsg[22].$descripfich."\n".$parametrosmodifica;
204                                $write = fputs($fp, $string);//Escribe la primera linea
205                                fclose($fp);
206
207                                        $action="./boot_grub4dos.php";
208                                        $mensaje=$TbMsg[7];
209                                }
210                ?>
211                <TABLE width="500" align=center border=1 >
212                <TR><TD align="center"><br><?php echo $mensaje;?><br><br><SPAN align=center class=subcabeceras><?php echo $modificadescripcion;?></span><br><br><br>
213                <form name="crearranque" method="post" action="<?php echo $action ?>">
214                <input type="hidden" name="litambito" value="<?php echo $litambito?>">
215                <input type="hidden" name="idambito" value="<?php echo $idambito?>">
216                <input type="hidden" name="nombreambito" value="<?php echo $nombreambito?>">
217                <input type="hidden" name="confirmado" value="0">
218                <input type="hidden" name="opcioncrear" value="modificar">
219                <input type="hidden" name="modo" value="0">
220                <input type="submit" value="Continuar" name="nuevoarran">
221                </form>
222                </TD></TR>
223                </TABLE>
224<?php
225//#########################################################################
226// MODO USUARIO
227//#########################################################################
228    // Mostramos las plantillas a modificar
229    } else {
230        $select="";
231        $input="";
232        $textoboton="";
233        // No hay plantilla elegida
234        if ($selectfile === "") {
235            // LEYENDO EL DIRECTORIO
236            // /var/lib/tftboot/menu.lst/templates o /var/lib/tftboot/grub/templates
237            chdir($dirtemplates);
238            $pn=glob("*");
239            // ordenamos
240            sort($pn);
241
242            if (empty($admin)) {
243                // Si el modo es usuario eliminamos las plantillas de la instalación
244                unset ($pn[array_search("pxe", $pn)]);
245                foreach ($pn as $key => $valor) {
246                    if (strnatcmp ( $valor , "20" ) > 0) break;
247                    unset($pn[$key]);
248
249                }
250
251                // Botón cambio de modo
252                $textoboton = '         <input type="submit" value='.$TbMsg[11].'  name="nuevoarran" onclick=\'document.forms[0].modo.value=1;\' >'."\n";
253            } else {
254                $textoboton = '         <input type="submit" value='.$TbMsg[10].'  name="nuevoarran" onclick=\'document.forms[0].modo.value=0;\'>'."\n";
255            }
256
257            // Opciones del select
258            $select = '  <select name="selectfile" id="selectfile" onChange="document.actualiza.submit()">'."\n".
259                      '              <option value=""></option>'."\n";
260            foreach ($pn as $valor) {
261                $descripcion=exec("awk 'NR==1 {print $2}' ".$dirtemplates.$valor);
262                $select.= '              <option value='.$valor.'>'.$descripcion.'</option>'."\n";
263            }
264            $select.= '          </select>'."\n";
265
266        // Hay una plantilla seleccionada para modificar
267        } else {
268            $file=$dirtemplates.$selectfile;
269            $descripcion=exec("awk 'NR==1 {print $2}' ".$dirtemplates.$selectfile);
270            $parametros=file_get_contents ($file);
271            // Elimino cabecera anterior
272            $parametros=preg_replace ("/$TbMsg[22].*\n/",'', $parametros);
273
274            // Campos de formulario especificos de esta opción
275            $input .= '<input type="hidden" name="nombrefichero" id="nombrefichero" value="'.$selectfile.'">'."\n".
276                      '<input type="hidden" name="confirmado" value="1" >'."\n";
277        }
278
279// Parte del formulario comun
280?>
281<form name="actualiza" method="post" action="<?php echo $action ?>">
282    <input type="hidden" name="litambito" value="<?php echo $litambito ?>">
283    <input type="hidden" name="idambito" value="<?php echo $idambito ?>">
284    <input type="hidden" name="nombreambito" value="<?php echo $nombreambito ?>">
285    <input type="hidden" name="opcioncrear" value="modificar">
286    <input type="hidden" name="boottype" value="<?php echo $boottype ?>">
287    <input type="hidden" name="modo" value="<?php echo $modo ?>">
288    <?php echo  $input;
289
290    // Cabecera de la tabla ?>
291    <table width="850" align="center" border="1" cellPadding="1" cellSpacing="1" class="tabla_datos" >
292      <tr>
293        <td height="70" colspan="3" valign="middle"><p align=center class=cabeceras><?php echo $TbMsg[4] ?></p>
294        <?php echo $textoboton ?>
295      </tr>
296   
297      <?php  // Lista de selección de plantillas
298        if ($selectfile === "") { ?>
299
300      <tr>
301        <td height="10" colspan="2" valign="middle"><span align=center class=subcabeceras><?php echo $TbMsg[9]." (".$boottype.")" ?></span></td>
302        <td height="10" valign="middle" align="right">
303        <?php echo $select ?>
304        </td>
305      </tr>
306   
307      <?php // Formulario con datos de la plantilla a cambiar
308        } else { ?>
309
310      <tr>
311        <td height="10" valign="middle">
312            <SPAN align=center class=subcabeceras><?php echo $TbMsg[21]." (".$boottype.")" ?></SPAN>
313        </td>
314        <td width="249" height="10" valign="middle"><?php echo $selectfile ?></td>
315        <td width="100" valign="middle" align="right">
316            <span align=center class=subcabeceras><?php echo $TbMsg[12] ?></span>
317            <input type="text" name="modificadescripcion" id="modificadescripcion" size="25" value="<?php echo $descripcion ?>">
318        </td>
319      </tr>
320      <tr>
321        <td width="500" height="100" valign="middle"> <span align=center class=subcabeceras><?php echo $TbMsg[19] ?></span></td>
322        <td width="500" height="100" colspan="2" valign="middle">
323            <textarea name="parametrosmodifica" id="parametrosmodifica" cols="95" rows="17"><?php echo $parametros ?></textarea>
324        </td>
325      </tr>
326      <tr>
327        <td width="500"  valign="middle"><input type="submit" value="<?php echo $TbMsg[13] ?>" name="nuevoarran"></td>
328        <td width="500" colspan="2"  valign="middle"><input type="submit" value="<?php echo $TbMsg[16] ?>" name="nuevoarran"  onclick='document.forms[0].action="./boot_grub4dos.php";'>
329      <tr>
330   
331       <?php  }
332        // Final pagina ?>
333    </table>
334</form>
335
336    <?php
337    }
338//##################################################################################################################################
339//###########  MODIFICAR COLUMNA ARRANQUE  #########################################################################################
340//##################################################################################################################################
341}
342
343
344//##################################################################################################################################
345//###########  ELIMINAR COLUMNA ARRANQUE  ##########################################################################################
346//##################################################################################################################################
347
348if ($opcioncrear == "eliminar" )
349        {
350        $confirmado=isset($_POST["confirmado"]) ? $_POST["confirmado"] : "";
351        if ($confirmado == 1)
352                {
353                        $eliminafichero=$_POST["eliminafichero"];
354                        $resul=actualizaequipos($cmd,$eliminafichero);
355                        $fichero = $dirtemplates.$eliminafichero;
356                        unlink($fichero);
357
358                ?>
359                <TABLE width="500" align=center border=1 >
360                <TR><TD align="center"><br><?php if($eliminafichero != null) echo $TbMsg[8];?><br><br><SPAN align=center class=subcabeceras><?php echo substr($eliminafichero,2)." (".$boottype.")"; ?></span><br><br><br>
361                <form name="crearranque" method="post" action="./boot_grub4dos.php">
362                <input type="hidden" name="litambito" value="<?php echo $litambito?>">
363                <input type="hidden" name="idambito" value="<?php echo $idambito?>">
364                <input type="hidden" name="nombreambito" value="<?php echo $nombreambito?>">
365                <input type="submit" value="Continuar" name="nuevoarran">
366                </form>
367                </TD></TR>
368</TABLE>
369
370                <?php }else{
371?>
372<?php
373//#########################################################################
374// LEYENDO EL DIRECTORIO
375// /var/lib/tftboot/menu.lst/templates o /var/lib/tftpboot/grub/templates/
376//#########################################################################
377//$dirtemplates= "/var/lib/tftpboot/menu.lst/templates/";
378chdir($dirtemplates);
379
380$pn=glob("*");//pila de nombres
381// No mostramos archivo pxe
382unset($pn[array_search("pxe", $pn)]);
383//ordenar las pilas segun la pila de nombres
384sort($pn);
385?>
386
387<form name="eliminaarranque" method="post" action="./boot_grub4dos_crear.php">
388<input type="hidden" name="litambito" value="<?php echo $litambito?>">
389<input type="hidden" name="idambito" value="<?php echo $idambito?>">
390<input type="hidden" name="nombreambito" value="<?php echo $nombreambito?>">
391<input type="hidden" name="confirmado" value="1">
392<input type="hidden" name="opcioncrear" value="eliminar">
393<input type="hidden" name="boottype" value="<?php echo $boottype ?>">
394<TABLE width="650" align=CENTER border=1 cellPadding=1 cellSpacing=1 class=tabla_datos >
395<TR align=center>
396        <TD height="70" colspan="2" valign="middle">
397                <SPAN align=center class=cabeceras> <?php echo $TbMsg[5]?> </SPAN>
398        </TD>
399  </TR>
400<TR>
401        <TD width="150" height="10" valign="middle">
402                <SPAN align=center class=subcabeceras><?php echo $TbMsg[12]." (".$boottype.")" ?></SPAN>
403        </TD>
404
405        <TD width="500" height="10" valign="middle">
406          <select name="eliminafichero" id="eliminafichero">
407        <?php
408                for ($z=0;$z<count($pn);$z++)
409                {
410                // Sólo se pueden borrar plantillas que empiecen >19
411                if((substr($pn[$z],0,2)) > 19)
412                        {
413                        $description=exec("awk 'NR==1 {print $2}' ".$dirtemplates.$pn[$z]);
414                        echo '<option value='.$pn[$z].'>'.$description.'</option>';
415                        }
416                }
417        ?>   
418      </select>
419        </TD>
420</TR>
421
422<TR>
423        <TD width="150"  valign="middle">
424                <input type="submit" value="<?php echo $TbMsg[13]?>" name="nuevoarra">
425               
426        </TD>
427
428        <TD width="500"  valign="middle">
429                <input type="submit" value="<?php echo $TbMsg[16]?>" name="nuevoarran" onclick='document.forms[0].action="./boot_grub4dos.php";'>
430        </TD>
431</TR>
432</TABLE>
433</form>
434<?php
435//##################################################################################################################################
436//###########  ELIMINAR COLUMNA ARRANQUE  ##########################################################################################
437//##################################################################################################################################
438}}?>
439
440</body>
441</html>
442
443<?php
444// Los equipos que tienen asignada la plantilla a eliminar se actualizan con el valor desconocido.
445// cmd: manejador de la base de datos
446// eliminafichero: plantilla a eliminar
447function actualizaequipos($cmd,$eliminafichero) {
448        $nombrefich="00unknown";
449        $cmd->texto="UPDATE ordenadores SET arranque='".$nombrefich."' WHERE arranque='".$eliminafichero."';";
450        $resul=$cmd->Ejecutar();
451        return $resul;
452}
453
454// Extrae los dos primeros caracteres de una cadena
455function principio($valor) {
456    return substr($valor,0,2);
457}
458?>
459
Note: See TracBrowser for help on using the repository browser.