source: admin/WebConsole/gestores/gestor_pxe_grub4dos.php @ ca0f9cfd

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-instalacionwebconsole3
Last change on this file since ca0f9cfd was 5bac736, checked in by ramon <ramongomez@…>, 13 years ago

Versión 1.0.4, #452: Integrar ticket de configuración de resolución de menús y cambios necesarios en la base de datos.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2915 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 4.5 KB
RevLine 
[8b2dce81]1<?php
2include_once("../includes/ctrlacc.php");
3include_once("../clases/AdoPhp.php");
4include_once("../clases/XmlPhp.php");
5include_once("../clases/MenuContextual.php");
6include_once("../clases/SockHidra.php");
7include_once("../includes/constantes.php");
8include_once("../includes/comunes.php");
9include_once("../includes/CreaComando.php");
10include_once("../idiomas/php/".$idioma."/aulas_".$idioma.".php");
11
12$cmd=CreaComando($cadenaconexion);
13if (!$cmd)
14        Header('Location: '.$pagerror.'?herror=2'); // Error de conexión con servidor B.D.
15//________________________________________________________________________________________________________
16
17
18echo "<html>";
19echo "<head>";
20echo "<meta http-equiv='Refresh' content='1;URL=../principal/boot.php?idambito=". $_GET['idaula'] ."&nombreambito=" . $_GET['nombreambito'] . "&litambito=" . $_GET['litambito'] . "'>";
21echo "<title> gestion de equipos </title>";
22echo "<base target='principal'>";
23echo "</head>";
24echo "<body>";
25
26
27
28#echo('litambito con valor:     '. $_GET['litambito']);
29#echo ('idambito con valor:      ' . $_GET['idaula']);
30#echo ('nombreambito con valor:      ' . $_GET['nombreambito']);
31
32$lista = explode(";",$_POST['listOfItems']);
33foreach ($lista as $sublista) {
34        $elementos = explode("|",$sublista);
35        $hostname=$elementos[1];
36        $optboot=$elementos[0];
[eaf2e6e]37        ogBootServer($cmd,$optboot,$hostname,$idioma);
[8b2dce81]38}
39echo " </body>";
40echo " </html> ";
41
[eaf2e6e]42function ogBootServer($cmd,$optboot,$hostname,$idioma)
[8b2dce81]43{       
44global $cmd;
45global $hostname;
46global $optboot;
[095d193]47global $retrun;
48$return="\n";
[8b2dce81]49$cmd->CreaParametro("@optboot",$optboot,0);
50$cmd->CreaParametro("@hostname",$hostname,0);
51$cmd->texto="update ordenadores set arranque=@optboot where nombreordenador=@hostname";
52$cmd->Ejecutar();
53$cmd->texto="SELECT ordenadores.ip AS ip, ordenadores.mac AS mac,
[5bac736]54                        ordenadores.netiface AS netiface, aulas.netmask AS netmask,
55                        aulas.router AS router, repositorios.ip AS iprepo,
56                        aulas.nombreaula AS grupo,
57                        menus.resolucion AS vga
58                        FROM ordenadores
59                        JOIN aulas ON ordenadores.idaula=aulas.idaula
60                        JOIN repositorios ON ordenadores.idrepositorio=repositorios.idrepositorio
61                        LEFT JOIN menus ON ordenadores.idmenu=menus.idmenu
62                        WHERE ordenadores.nombreordenador='". $hostname ."'";
63
64
65
[8b2dce81]66$rs=new Recordset;
67$rs->Comando=&$cmd;
68if (!$rs->Abrir()) echo "error";
69$rs->Primero();
70        $mac=$rs->campos["mac"];
71        $netiface=$rs->campos["netiface"];
72        $ip=$rs->campos["ip"];
73        $router=$rs->campos["router"];
74        $netmask=$rs->campos["netmask"];
75        $repo=$rs->campos["iprepo"];                   
[fa4129c]76        $group=cleanString($rs->campos["grupo"]);
[5bac736]77        if($rs->campos["vga"]== null)
78                $vga="788";
79        else
80                $vga=$rs->campos["vga"];
81
[8b2dce81]82$rs->Cerrar();
83
[fa4129c]84$cmd->texto="SELECT ipserveradm FROM entornos";
[ea5fbb9]85$rs=new Recordset;
86$rs->Comando=&$cmd;
87if (!$rs->Abrir()) echo "error";
88
89$rs->Primero();
90        $server=$rs->campos["ipserveradm"];
91$rs->Cerrar();
92
[eaf2e6e]93
94switch ($idioma) {
95    case eng:
96        $idioma=en_GB;
97        break;
98    case esp:
99        $idioma=es_ES;
100        break;
101    case cat:
[09468cb]102        $idioma=ca_ES;
[eaf2e6e]103        break;
104}
105
106
[5bac736]107$infohost=" vga=$vga".
108          " LANG=$idioma".
109          " ip=$ip:$server:$router:$netmask:$hostname:$netiface:none" .
[fa4129c]110          " group=$group" .
111          " ogrepo=$repo" .
112          " oglive=$repo" .
113          " oglog=$server" .
[5bac736]114          " ogshare=$server";
[ea5fbb9]115
116
[8b2dce81]117###################obtenemos las variables de red del aula.
118
[5bac736]119#02.1 obtenemos nombre fichero mac
120$pxedir="/opt/opengnsys/tftpboot/menu.lst";
121$mac=  substr($mac,0,2) . ":" . substr($mac,2,2) . ":" . substr($mac,4,2) . ":" . substr($mac,6,2) . ":" . substr($mac,8,2) . ":" . substr($mac,10,2);
122$macfile="$pxedir/01-" . str_replace(":","-",strtoupper($mac));
[8b2dce81]123
[4a80437]124#controlar optboot
[8b2dce81]125
[5bac736]126exec("sed -e 's/vga=...//g' -e 's/INFOHOST/$infohost/g' $pxedir/templates/$optboot > $macfile");
127exec("chown www-data:www-data $macfile");
128exec("chmod 777 $macfile");
[8b2dce81]129
130}
131
[5bac736]132
[8b2dce81]133function netmask2cidr($netmask) {
134          $cidr = 0;
135          foreach (explode('.', $netmask) as $number) {
136              for (;$number> 0; $number = ($number <<1) % 256) {
137                  $cidr++;
138               }
139           }
140           return $cidr;
141 }
142
[fa4129c]143// Sustituye espacio por "_" y quita acentos y tildes.
144function cleanString ($cadena) {
145        $patron = array ('/ /','/á/','/é/','/í/','/ó/','/ú/','/ñ/','/Á/','/É/','/Í/','/Ó/','/Ú/','/Ñ/');
146        $reemplazo = array ('_','a','e','i','o','u','n','A','E','I','O','U','N');
147        return  preg_replace($patron,$reemplazo,$cadena);
148}
149
150?>
Note: See TracBrowser for help on using the repository browser.