| 1 | <?php | 
|---|
| 2 | //importando nuestras las referencias XAJAX | 
|---|
| 3 | require ("xajax.common.php"); | 
|---|
| 4 |  | 
|---|
| 5 |  | 
|---|
| 6 | //funcion que lista las Particiones segun la IP elegida | 
|---|
| 7 | function ListarOrigenMaster($ip){ | 
|---|
| 8 |  | 
|---|
| 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"); | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | //instanciamos el objeto para la respuesta AJAX | 
|---|
| 18 | $objResponse = new xajaxResponse(); | 
|---|
| 19 |  | 
|---|
| 20 | $SelectHtml=" "; | 
|---|
| 21 | $SelectHtml='<select name="source"> '; | 
|---|
| 22 |  | 
|---|
| 23 | $cmd=CreaComando($cadenaconexion); | 
|---|
| 24 | $rs=new Recordset; | 
|---|
| 25 |  | 
|---|
| 26 | //Primera consulta: Particiones del MASTER potencialmente clonables. | 
|---|
| 27 | $cmd->texto='SELECT ordenadores_particiones.numdisk as DISK,ordenadores_particiones.numpar as PART,nombresos.nombreso as OS | 
|---|
| 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 | 
|---|
| 34 | ORDER BY ordenadores_particiones.numdisk,ordenadores_particiones.numpar'; | 
|---|
| 35 | $rs->Comando=&$cmd; | 
|---|
| 36 |  | 
|---|
| 37 | if ($rs->Abrir()){ | 
|---|
| 38 | $cantRegistros=$rs->numeroderegistros; | 
|---|
| 39 | if($cantRegistros>0){ | 
|---|
| 40 | $rs->Primero(); | 
|---|
| 41 | while (!$rs->EOF){ | 
|---|
| 42 | $SelectHtml.='<OPTION value=" '.$rs->campos["DISK"].' '.$rs->campos["PART"].'"'; | 
|---|
| 43 | $SelectHtml.='>'; | 
|---|
| 44 | $SelectHtml.='DISK '.$rs->campos["DISK"].',PART '.$rs->campos["PART"].': '. $rs->campos["OS"].'</OPTION>'; | 
|---|
| 45 | $rs->Siguiente(); | 
|---|
| 46 | } | 
|---|
| 47 | } | 
|---|
| 48 | else | 
|---|
| 49 | { | 
|---|
| 50 | $objResponse->alert("No partion found in this host for use it to cloning other computers."); | 
|---|
| 51 | } | 
|---|
| 52 | $rs->Cerrar(); | 
|---|
| 53 | } | 
|---|
| 54 | //Segunda consulta: Imagenes del MASTER registradas como si fuese un repo. | 
|---|
| 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 |  | 
|---|
| 60 | $cmd->texto='select cache  from ordenadores_particiones where codpar = 202 and  idordenador = (SELECT idordenador from ordenadores where ip="' .$ip . '")'; | 
|---|
| 61 | $rs->Comando=&$cmd; | 
|---|
| 62 |  | 
|---|
| 63 | if ($rs->Abrir()){ | 
|---|
| 64 | $cantRegistros=$rs->numeroderegistros; | 
|---|
| 65 | if($cantRegistros>0){ | 
|---|
| 66 | $rs->Primero(); | 
|---|
| 67 | while (!$rs->EOF){ | 
|---|
| 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 | } | 
|---|
| 77 | $rs->Siguiente(); | 
|---|
| 78 | } | 
|---|
| 79 | } | 
|---|
| 80 | else | 
|---|
| 81 | { | 
|---|
| 82 | $objResponse->alert("No image found in CACHE in this host for use it to cloning other compuers."); | 
|---|
| 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 | 
|---|
| 90 | where repositorios.idrepositorio=(select idrepositorio from ordenadores where ordenadores.ip="' .$ip .'") ORDER BY imagenes.descripcion'; | 
|---|
| 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.='>'; | 
|---|
| 101 | $SelectHtml.='IMG-REPO: ' . $rs->campos["descripcion"].'</OPTION>'; | 
|---|
| 102 | $rs->Siguiente(); | 
|---|
| 103 | } | 
|---|
| 104 | } | 
|---|
| 105 | else | 
|---|
| 106 | { | 
|---|
| 107 | $objResponse->alert("No image found in REPO from this host for use it to cloning other computers."); | 
|---|
| 108 | } | 
|---|
| 109 | $rs->Cerrar(); | 
|---|
| 110 | } | 
|---|
| 111 |  | 
|---|
| 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); | 
|---|
| 116 |  | 
|---|
| 117 | return $objResponse; //retornamos la respuesta AJAX | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | $xajax->processRequest(); //procesando cualquier peticion AJAX | 
|---|
| 121 |  | 
|---|
| 122 |  | 
|---|
| 123 |  | 
|---|
| 124 |  | 
|---|
| 125 | ?> | 
|---|