[18779c5] | 1 | <?php |
---|
[eb3e2b8] | 2 | //importando nuestras las referencias XAJAX |
---|
| 3 | require ("xajax.common.php"); |
---|
| 4 | |
---|
| 5 | |
---|
[18779c5] | 6 | //funcion que lista las Particiones segun la IP elegida |
---|
[81f4945] | 7 | function ListarOrigenMaster($ip){ |
---|
[eb3e2b8] | 8 | |
---|
[81f4945] | 9 | include_once("../includes/ctrlacc.php"); |
---|
| 10 | include_once("../clases/AdoPhp.php"); |
---|
| 11 | include_once("../includes/constantes.php"); |
---|
| 12 | include_once("../includes/comunes.php"); |
---|
| 13 | include_once("../includes/CreaComando.php"); |
---|
| 14 | include_once("../includes/HTMLSELECT.php"); |
---|
[eb3e2b8] | 15 | |
---|
| 16 | |
---|
[81f4945] | 17 | //instanciamos el objeto para la respuesta AJAX |
---|
| 18 | $objResponse = new xajaxResponse(); |
---|
[eb3e2b8] | 19 | |
---|
[81f4945] | 20 | $SelectHtml=" "; |
---|
[eb9424f] | 21 | $SelectHtml='<select name="source"> '; |
---|
| 22 | |
---|
[81f4945] | 23 | $cmd=CreaComando($cadenaconexion); |
---|
[eb9424f] | 24 | $rs=new Recordset; |
---|
| 25 | |
---|
| 26 | //Primera consulta: Particiones del MASTER potencialmente clonables. |
---|
[18779c5] | 27 | $cmd->texto='SELECT ordenadores_particiones.numdisk as DISK,ordenadores_particiones.numpar as PART,nombresos.nombreso as OS |
---|
[eb3e2b8] | 28 | FROM ordenadores_particiones INNER JOIN tipospar ON tipospar.codpar=ordenadores_particiones.codpar |
---|
| 29 | INNER JOIN nombresos ON ordenadores_particiones.idnombreso=nombresos.idnombreso |
---|
| 30 | INNER JOIN ordenadores ON ordenadores_particiones.idordenador=ordenadores.idordenador |
---|
| 31 | WHERE ordenadores.ip="' .$ip . '" |
---|
| 32 | AND tipospar.clonable>0 |
---|
| 33 | AND ordenadores_particiones.idnombreso>0 |
---|
[18779c5] | 34 | ORDER BY ordenadores_particiones.numdisk,ordenadores_particiones.numpar'; |
---|
[81f4945] | 35 | $rs->Comando=&$cmd; |
---|
[18779c5] | 36 | |
---|
| 37 | if ($rs->Abrir()){ |
---|
[81f4945] | 38 | $cantRegistros=$rs->numeroderegistros; |
---|
| 39 | if($cantRegistros>0){ |
---|
[eb9424f] | 40 | $rs->Primero(); |
---|
[81f4945] | 41 | while (!$rs->EOF){ |
---|
[18779c5] | 42 | $SelectHtml.='<OPTION value=" '.$rs->campos["DISK"].' '.$rs->campos["PART"].'"'; |
---|
[81f4945] | 43 | $SelectHtml.='>'; |
---|
[18779c5] | 44 | $SelectHtml.='DISK '.$rs->campos["DISK"].',PART '.$rs->campos["PART"].': '. $rs->campos["OS"].'</OPTION>'; |
---|
[81f4945] | 45 | $rs->Siguiente(); |
---|
| 46 | } |
---|
[eb3e2b8] | 47 | } |
---|
[81f4945] | 48 | else |
---|
[eb9424f] | 49 | { |
---|
[230e577] | 50 | $objResponse->alert("No partion found in this host for use it to cloning other computers."); |
---|
[81f4945] | 51 | } |
---|
| 52 | $rs->Cerrar(); |
---|
| 53 | } |
---|
[eb9424f] | 54 | //Segunda consulta: Imagenes del MASTER registradas como si fuese un repo. |
---|
[29b025f] | 55 | |
---|
| 56 | # $cmd->texto='SELECT *,repositorios.ip as iprepositorio FROM imagenes |
---|
| 57 | #INNER JOIN repositorios ON repositorios.idrepositorio=imagenes.idrepositorio |
---|
| 58 | #where repositorios.ip="' .$ip .'"'; |
---|
| 59 | |
---|
[18779c5] | 60 | $cmd->texto='select cache from ordenadores_particiones where codpar = 202 and idordenador = (SELECT idordenador from ordenadores where ip="' .$ip . '")'; |
---|
[eb9424f] | 61 | $rs->Comando=&$cmd; |
---|
| 62 | |
---|
| 63 | if ($rs->Abrir()){ |
---|
| 64 | $cantRegistros=$rs->numeroderegistros; |
---|
| 65 | if($cantRegistros>0){ |
---|
| 66 | $rs->Primero(); |
---|
| 67 | while (!$rs->EOF){ |
---|
[29b025f] | 68 | $files = explode(",", $rs->campos["cache"]); |
---|
| 69 | foreach ($files as $file) { |
---|
| 70 | if ( preg_match ( "/img$/", $file ) ) { |
---|
| 71 | $imgname = rtrim($file, ".img"); |
---|
| 72 | $SelectHtml.='<OPTION value=" CACHE /'.ltrim($imgname).'"'; |
---|
| 73 | $SelectHtml.='>'; |
---|
| 74 | $SelectHtml.='IMG-CACHE: ' . ltrim($imgname).'</OPTION>'; |
---|
| 75 | } |
---|
| 76 | } |
---|
[eb9424f] | 77 | $rs->Siguiente(); |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | else |
---|
| 81 | { |
---|
[230e577] | 82 | $objResponse->alert("No image found in CACHE in this host for use it to cloning other compuers."); |
---|
[eb9424f] | 83 | } |
---|
| 84 | $rs->Cerrar(); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | //Tercera consulta: Imagenes del REPO, que el MASTER se encargara de enivarlas |
---|
| 88 | $cmd->texto='SELECT *,repositorios.ip as iprepositorio FROM imagenes |
---|
| 89 | INNER JOIN repositorios ON repositorios.idrepositorio=imagenes.idrepositorio |
---|
[df5a611] | 90 | where repositorios.idrepositorio=(select idrepositorio from ordenadores where ordenadores.ip="' .$ip .'") ORDER BY imagenes.descripcion'; |
---|
[eb9424f] | 91 | |
---|
| 92 | $rs->Comando=&$cmd; |
---|
| 93 | |
---|
| 94 | if ($rs->Abrir()){ |
---|
| 95 | $cantRegistros=$rs->numeroderegistros; |
---|
| 96 | if($cantRegistros>0){ |
---|
| 97 | $rs->Primero(); |
---|
| 98 | while (!$rs->EOF){ |
---|
| 99 | $SelectHtml.='<OPTION value=" REPO /'.$rs->campos["nombreca"].'"'; |
---|
| 100 | $SelectHtml.='>'; |
---|
[df5a611] | 101 | $SelectHtml.='IMG-REPO: ' . $rs->campos["descripcion"].'</OPTION>'; |
---|
[eb9424f] | 102 | $rs->Siguiente(); |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | else |
---|
| 106 | { |
---|
[230e577] | 107 | $objResponse->alert("No image found in REPO from this host for use it to cloning other computers."); |
---|
[eb9424f] | 108 | } |
---|
| 109 | $rs->Cerrar(); |
---|
| 110 | } |
---|
| 111 | |
---|
[81f4945] | 112 | $SelectHtml.= '</SELECT>'; |
---|
| 113 | |
---|
| 114 | //asignando el contenido de la varabiale $SelectHTML al div que esta en la paquina inicial |
---|
| 115 | $objResponse->assign("divListado","innerHTML",$SelectHtml); |
---|
[18779c5] | 116 | |
---|
[eb3e2b8] | 117 | return $objResponse; //retornamos la respuesta AJAX |
---|
| 118 | } |
---|
| 119 | |
---|
[18779c5] | 120 | $xajax->processRequest(); //procesando cualquier peticion AJAX |
---|
[81f4945] | 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|
[29b025f] | 125 | ?> |
---|