[eb3e2b8] | 1 | <?php |
---|
| 2 | //importando nuestras las referencias XAJAX |
---|
| 3 | require ("xajax.common.php"); |
---|
| 4 | |
---|
| 5 | |
---|
[81f4945] | 6 | //función que lista las Particiones segun la IP elegida |
---|
| 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. |
---|
[81f4945] | 27 | $cmd->texto='SELECT 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 |
---|
| 34 | ORDER BY ordenadores_particiones.numpar'; |
---|
[eb9424f] | 35 | |
---|
[81f4945] | 36 | $rs->Comando=&$cmd; |
---|
[eb9424f] | 37 | |
---|
[81f4945] | 38 | if ($rs->Abrir()){ |
---|
| 39 | $cantRegistros=$rs->numeroderegistros; |
---|
| 40 | if($cantRegistros>0){ |
---|
[eb9424f] | 41 | $rs->Primero(); |
---|
[81f4945] | 42 | while (!$rs->EOF){ |
---|
[eb9424f] | 43 | $SelectHtml.='<OPTION value=" 1 '.$rs->campos["PART"].'"'; |
---|
[81f4945] | 44 | $SelectHtml.='>'; |
---|
[eb9424f] | 45 | $SelectHtml.='PART: '. $rs->campos["OS"].'</OPTION>'; |
---|
[81f4945] | 46 | $rs->Siguiente(); |
---|
| 47 | } |
---|
[eb3e2b8] | 48 | } |
---|
[81f4945] | 49 | else |
---|
[eb9424f] | 50 | { |
---|
[230e577] | 51 | $objResponse->alert("No partion found in this host for use it to cloning other computers."); |
---|
[81f4945] | 52 | } |
---|
| 53 | $rs->Cerrar(); |
---|
| 54 | } |
---|
[eb9424f] | 55 | |
---|
| 56 | //Segunda consulta: Imagenes del MASTER registradas como si fuese un repo. |
---|
[29b025f] | 57 | |
---|
| 58 | # $cmd->texto='SELECT *,repositorios.ip as iprepositorio FROM imagenes |
---|
| 59 | #INNER JOIN repositorios ON repositorios.idrepositorio=imagenes.idrepositorio |
---|
| 60 | #where repositorios.ip="' .$ip .'"'; |
---|
| 61 | |
---|
| 62 | $cmd->texto='select cache from ordenadores_particiones where codpar = 202 and idordenador = (SELECT idordenador from ordenadores where ip="' .$ip . '")'; |
---|
[eb9424f] | 63 | |
---|
| 64 | $rs->Comando=&$cmd; |
---|
| 65 | |
---|
| 66 | if ($rs->Abrir()){ |
---|
| 67 | $cantRegistros=$rs->numeroderegistros; |
---|
| 68 | if($cantRegistros>0){ |
---|
| 69 | $rs->Primero(); |
---|
| 70 | while (!$rs->EOF){ |
---|
[29b025f] | 71 | $files = explode(",", $rs->campos["cache"]); |
---|
| 72 | foreach ($files as $file) { |
---|
| 73 | if ( preg_match ( "/img$/", $file ) ) { |
---|
| 74 | $imgname = rtrim($file, ".img"); |
---|
| 75 | $SelectHtml.='<OPTION value=" CACHE /'.ltrim($imgname).'"'; |
---|
| 76 | $SelectHtml.='>'; |
---|
| 77 | $SelectHtml.='IMG-CACHE: ' . ltrim($imgname).'</OPTION>'; |
---|
| 78 | } |
---|
| 79 | } |
---|
[eb9424f] | 80 | $rs->Siguiente(); |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | else |
---|
| 84 | { |
---|
[230e577] | 85 | $objResponse->alert("No image found in CACHE in this host for use it to cloning other compuers."); |
---|
[eb9424f] | 86 | } |
---|
| 87 | $rs->Cerrar(); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | //Tercera consulta: Imagenes del REPO, que el MASTER se encargara de enivarlas |
---|
| 91 | $cmd->texto='SELECT *,repositorios.ip as iprepositorio FROM imagenes |
---|
| 92 | INNER JOIN repositorios ON repositorios.idrepositorio=imagenes.idrepositorio |
---|
| 93 | where repositorios.idrepositorio=(select idrepositorio from ordenadores where ordenadores.ip="' .$ip .'")'; |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | $rs->Comando=&$cmd; |
---|
| 97 | |
---|
| 98 | if ($rs->Abrir()){ |
---|
| 99 | $cantRegistros=$rs->numeroderegistros; |
---|
| 100 | if($cantRegistros>0){ |
---|
| 101 | $rs->Primero(); |
---|
| 102 | while (!$rs->EOF){ |
---|
| 103 | $SelectHtml.='<OPTION value=" REPO /'.$rs->campos["nombreca"].'"'; |
---|
| 104 | $SelectHtml.='>'; |
---|
| 105 | $SelectHtml.='IMG-REPO: ' . $rs->campos["nombreca"].'</OPTION>'; |
---|
| 106 | $rs->Siguiente(); |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | else |
---|
| 110 | { |
---|
[230e577] | 111 | $objResponse->alert("No image found in REPO from this host for use it to cloning other computers."); |
---|
[eb9424f] | 112 | } |
---|
| 113 | $rs->Cerrar(); |
---|
| 114 | } |
---|
| 115 | |
---|
[81f4945] | 116 | $SelectHtml.= '</SELECT>'; |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | //asignando el contenido de la varabiale $SelectHTML al div que esta en la paquina inicial |
---|
| 120 | $objResponse->assign("divListado","innerHTML",$SelectHtml); |
---|
| 121 | |
---|
| 122 | |
---|
[eb3e2b8] | 123 | return $objResponse; //retornamos la respuesta AJAX |
---|
| 124 | } |
---|
| 125 | |
---|
[81f4945] | 126 | $xajax->processRequest(); //procesando cualquier petición AJAX |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|
[29b025f] | 131 | ?> |
---|