| [3ec149c] | 1 | <? | 
|---|
|  | 2 | // ************************************************************************************************************************************************* | 
|---|
|  | 3 | // Aplicación WEB: ogAdmWebCon | 
|---|
|  | 4 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla | 
|---|
|  | 5 | // Fecha Creación: Año 2009-2010 | 
|---|
|  | 6 | // Fecha Última modificación: Agosto-2010 | 
|---|
|  | 7 | // Nombre del fichero: gestor_tareascomandos.php | 
|---|
|  | 8 | // Descripción : | 
|---|
|  | 9 | //              Gestiona el mantenimiento de la tabla de tareas_comandos | 
|---|
|  | 10 | // ************************************************************************************************************************************************* | 
|---|
|  | 11 | include_once("../includes/ctrlacc.php"); | 
|---|
|  | 12 | include_once("../clases/AdoPhp.php"); | 
|---|
|  | 13 | include_once("../includes/CreaComando.php"); | 
|---|
|  | 14 | include_once("../includes/opciones.php"); | 
|---|
|  | 15 | include_once("../clases/SockHidra.php"); | 
|---|
|  | 16 | include_once("../includes/constantes.php"); | 
|---|
|  | 17 | //________________________________________________________________________________________________________ | 
|---|
|  | 18 | $opcion=0; // Inicializa parametros | 
|---|
|  | 19 | $idtareacomando=0; | 
|---|
|  | 20 | $orden=0; | 
|---|
|  | 21 |  | 
|---|
|  | 22 | if (isset($_POST["opcion"])) $opcion=$_POST["opcion"]; // Recoge parametros | 
|---|
|  | 23 | if (isset($_POST["idtareacomando"])) $idtareacomando=$_POST["idtareacomando"]; | 
|---|
|  | 24 | if (isset($_POST["orden"])) $orden=$_POST["orden"]; | 
|---|
|  | 25 |  | 
|---|
|  | 26 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando | 
|---|
|  | 27 | $resul=false; | 
|---|
|  | 28 | if ($cmd){ | 
|---|
|  | 29 | $resul=Gestiona(); | 
|---|
|  | 30 | $cmd->Conexion->Cerrar(); | 
|---|
|  | 31 | } | 
|---|
|  | 32 | $literal=""; | 
|---|
|  | 33 | switch($opcion){ | 
|---|
|  | 34 | case $op_eliminacion : | 
|---|
|  | 35 | $literal="resultado_eliminar_tareacomando"; | 
|---|
|  | 36 | break; | 
|---|
|  | 37 | case $op_modificacion : | 
|---|
|  | 38 | $literal="resultado_modificar_tareacomando"; | 
|---|
|  | 39 | break; | 
|---|
|  | 40 | case $op_ejecucion : | 
|---|
|  | 41 | $literal="resultado_ejecutar_tareacomando"; | 
|---|
|  | 42 | break; | 
|---|
|  | 43 | default: | 
|---|
|  | 44 | break; | 
|---|
|  | 45 | } | 
|---|
|  | 46 | if ($resul){ | 
|---|
|  | 47 | echo $literal."(1,'".$cmd->DescripUltimoError()." ',".$idtareacomando.");".chr(13); | 
|---|
|  | 48 | } | 
|---|
|  | 49 | else{ | 
|---|
|  | 50 | echo $literal."(0,'".$cmd->DescripUltimoError()."',".$idtareacomando.")"; | 
|---|
|  | 51 | } | 
|---|
|  | 52 | // ************************************************************************************************************************************************* | 
|---|
|  | 53 | function Gestiona(){ | 
|---|
|  | 54 | global $cmd; | 
|---|
|  | 55 | global $opcion; | 
|---|
|  | 56 | global $op_modificacion; | 
|---|
|  | 57 | global $op_eliminacion; | 
|---|
|  | 58 | global $op_ejecucion; | 
|---|
|  | 59 | global $EJECUCION_COMANDO; | 
|---|
|  | 60 | global $PROCESOS; | 
|---|
|  | 61 | global $ACCION_INICIADA; | 
|---|
|  | 62 | global $ACCION_SINERRORES; | 
|---|
|  | 63 | global $servidorhidra; | 
|---|
|  | 64 | global $hidraport; | 
|---|
|  | 65 | global $idcentro; | 
|---|
|  | 66 | global $idtareacomando; | 
|---|
|  | 67 | global $orden; | 
|---|
|  | 68 |  | 
|---|
|  | 69 | $cmd->CreaParametro("@orden",$orden,1); | 
|---|
|  | 70 |  | 
|---|
|  | 71 | switch($opcion){ | 
|---|
|  | 72 | case $op_modificacion : | 
|---|
|  | 73 | $cmd->texto='UPDATE tareas_comandos set orden=@orden WHERE idtareacomando='.$idtareacomando; | 
|---|
|  | 74 | $resul=$cmd->Ejecutar(); | 
|---|
|  | 75 | break; | 
|---|
|  | 76 | case $op_eliminacion : | 
|---|
|  | 77 | $cmd->texto='DELETE  FROM tareas_comandos WHERE idtareacomando='.$idtareacomando; | 
|---|
|  | 78 | $resul=$cmd->Ejecutar(); | 
|---|
|  | 79 | break; | 
|---|
|  | 80 | case $op_ejecucion : | 
|---|
|  | 81 | $nombreliterales[0]="idcomando"; | 
|---|
|  | 82 | $nombreliterales[1]="ambito"; | 
|---|
|  | 83 | $nombreliterales[2]="idambito"; | 
|---|
|  | 84 | $nombreliterales[3]="parametros"; | 
|---|
|  | 85 | $Datos=TomanDatos($cmd,"tareas_comandos",$idtareacomando,"idtareacomando",$nombreliterales); | 
|---|
|  | 86 | if(empty($Datos)) return(false); | 
|---|
|  | 87 |  | 
|---|
|  | 88 | $idtipoaccion=$Datos["idcomando"]; | 
|---|
|  | 89 | $ambito=$Datos["ambito"]; | 
|---|
|  | 90 | $idambito=$Datos["idambito"]; | 
|---|
|  | 91 | $parametros=$Datos["parametros"]; | 
|---|
|  | 92 |  | 
|---|
|  | 93 | $resul=true; | 
|---|
|  | 94 |  | 
|---|
|  | 95 | $cmd->CreaParametro("@tipoaccion",$EJECUCION_COMANDO,1); | 
|---|
|  | 96 | $cmd->CreaParametro("@idtipoaccion",$idtipoaccion,1); | 
|---|
|  | 97 | $cmd->CreaParametro("@cateaccion",$PROCESOS,1); | 
|---|
|  | 98 | $cmd->CreaParametro("@ambito",$ambito,1); | 
|---|
|  | 99 | $cmd->CreaParametro("@idambito",$idambito,1); | 
|---|
|  | 100 | $cmd->CreaParametro("@ambitskwrk","",0); | 
|---|
|  | 101 | $cmd->CreaParametro("@fechahorareg",date("y/m/d H:i:s"),0); | 
|---|
|  | 102 | $cmd->CreaParametro("@estado",$ACCION_INICIADA,0); | 
|---|
|  | 103 | $cmd->CreaParametro("@resultado",$ACCION_SINRESULTADO,0); | 
|---|
|  | 104 | $cmd->CreaParametro("@idcentro",$idcentro,1); | 
|---|
|  | 105 | $cmd->CreaParametro("@parametros",$parametros,0); | 
|---|
|  | 106 | $cmd->texto="INSERT INTO acciones (tipoaccion,idtipoaccion,cateaccion,ambito,idambito,ambitskwrk,fechahorareg,estado,resultado,idcentro,parametros,accionid) VALUES (@tipoaccion,@idtipoaccion,@cateaccion,@ambito,@idambito,@ambitskwrk,@fechahorareg,@estado,@resultado,@idcentro,@parametros,0)"; | 
|---|
|  | 107 | $resul=$cmd->Ejecutar(); | 
|---|
|  | 108 | if($resul){ | 
|---|
|  | 109 | $parametros.="ids=".$cmd->Autonumerico().chr(13); | 
|---|
|  | 110 | } | 
|---|
|  | 111 | $shidra=new SockHidra($servidorhidra,$hidraport); | 
|---|
|  | 112 | if ($shidra->conectar()){ // Se ha establecido la conexión con el servidor hidra | 
|---|
|  | 113 | $shidra->envia_comando($parametros); | 
|---|
|  | 114 | $shidra->desconectar(); | 
|---|
|  | 115 | } | 
|---|
|  | 116 | break; | 
|---|
|  | 117 | default: | 
|---|
|  | 118 | break; | 
|---|
|  | 119 | } | 
|---|
|  | 120 | return($resul); | 
|---|
|  | 121 | } | 
|---|
|  | 122 | ?> | 
|---|