source: admin/WebConsole/gestores/gestor_pxe_grub4dos.php @ 4a03527

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 4a03527 was 09468cb, checked in by ramon <ramongomez@…>, 13 years ago

Versión 1.0.3, #483: Código correcto para idioma catalán.

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

  • Property mode set to 100644
File size: 4.3 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
54$cmd->texto="SELECT ordenadores.ip AS ip, ordenadores.mac AS mac,
[fa4129c]55                        ordenadores.netiface AS netiface, aulas.netmask AS netmask,
56                        aulas.router AS router, repositorios.ip AS iprepo,
57                        aulas.nombreaula AS grupo
58                        FROM ordenadores
59                        JOIN aulas ON ordenadores.idaula=aulas.idaula
60                        JOIN repositorios ON ordenadores.idrepositorio=repositorios.idrepositorio
61                        WHERE ordenadores.nombreordenador='". $hostname ."'";
[8b2dce81]62$rs=new Recordset;
63$rs->Comando=&$cmd;
64if (!$rs->Abrir()) echo "error";
65$rs->Primero();
66        $mac=$rs->campos["mac"];
67        $netiface=$rs->campos["netiface"];
68        $ip=$rs->campos["ip"];
69        $router=$rs->campos["router"];
70        $netmask=$rs->campos["netmask"];
71        $repo=$rs->campos["iprepo"];                   
[fa4129c]72        $group=cleanString($rs->campos["grupo"]);
[8b2dce81]73$rs->Cerrar();
74
[fa4129c]75$cmd->texto="SELECT ipserveradm FROM entornos";
[ea5fbb9]76$rs=new Recordset;
77$rs->Comando=&$cmd;
78if (!$rs->Abrir()) echo "error";
79
80$rs->Primero();
81        $server=$rs->campos["ipserveradm"];
82$rs->Cerrar();
83
[eaf2e6e]84
85switch ($idioma) {
86    case eng:
87        $idioma=en_GB;
88        break;
89    case esp:
90        $idioma=es_ES;
91        break;
92    case cat:
[09468cb]93        $idioma=ca_ES;
[eaf2e6e]94        break;
95}
96
97
98$infohost="'LANG=$idioma ip=$ip:$server:$router:$netmask:$hostname:$netiface:none" .
[fa4129c]99          " group=$group" .
100          " ogrepo=$repo" .
101          " oglive=$repo" .
102          " oglog=$server" .
103          " ogshare=$server'";
[ea5fbb9]104
105
[8b2dce81]106###################obtenemos las variables de red del aula.
107
108        #02.1 obtenemos nombre fichero mac
109        $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);
[095d193]110        $macfile="01-" . str_replace(":","-",strtoupper($mac));
111        $nombre_archivo="/var/lib/tftpboot/menu.lst/" . $macfile;
[8b2dce81]112
[4a80437]113#controlar optboot
[8b2dce81]114
[4a80437]115        #exec("cp /var/lib/tftpboot/menu.lst/templates/". $optboot . " /var/lib/tftpboot/menu.lst/". $macfile);
116        exec("sed s/INFOHOST/".$infohost."/g /var/lib/tftpboot/menu.lst/templates/" . $optboot . " > /var/lib/tftpboot/menu.lst/" . $macfile);
117        exec("chown www-data:www-data /var/lib/tftpboot/menu.lst/". $macfile);
118        exec("chmod 777 /var/lib/tftpboot/menu.lst/". $macfile);
[8b2dce81]119       
120
121
122
123}
124
125function netmask2cidr($netmask) {
126          $cidr = 0;
127          foreach (explode('.', $netmask) as $number) {
128              for (;$number> 0; $number = ($number <<1) % 256) {
129                  $cidr++;
130               }
131           }
132           return $cidr;
133 }
134
[fa4129c]135// Sustituye espacio por "_" y quita acentos y tildes.
136function cleanString ($cadena) {
137        $patron = array ('/ /','/á/','/é/','/í/','/ó/','/ú/','/ñ/','/Á/','/É/','/Í/','/Ó/','/Ú/','/Ñ/');
138        $reemplazo = array ('_','a','e','i','o','u','n','A','E','I','O','U','N');
139        return  preg_replace($patron,$reemplazo,$cadena);
140}
141
142?>
Note: See TracBrowser for help on using the repository browser.