1 | <?php |
---|
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 $ACCION_SINRESULTADO; |
---|
64 | global $servidorhidra; |
---|
65 | global $hidraport; |
---|
66 | global $idcentro; |
---|
67 | global $idtareacomando; |
---|
68 | global $orden; |
---|
69 | $resul=true; |
---|
70 | |
---|
71 | $cmd->CreaParametro("@orden",$orden,1); |
---|
72 | |
---|
73 | switch($opcion){ |
---|
74 | case $op_modificacion : |
---|
75 | $cmd->texto='UPDATE tareas_comandos set orden=@orden WHERE idtareacomando='.$idtareacomando; |
---|
76 | $resul=$cmd->Ejecutar(); |
---|
77 | break; |
---|
78 | case $op_eliminacion : |
---|
79 | $cmd->texto='DELETE FROM tareas_comandos WHERE idtareacomando='.$idtareacomando; |
---|
80 | $resul=$cmd->Ejecutar(); |
---|
81 | break; |
---|
82 | case $op_ejecucion : |
---|
83 | $nombreliterales[0]="idcomando"; |
---|
84 | $nombreliterales[1]="ambito"; |
---|
85 | $nombreliterales[2]="idambito"; |
---|
86 | $nombreliterales[3]="parametros"; |
---|
87 | $Datos=TomanDatos($cmd,"tareas_comandos",$idtareacomando,"idtareacomando",$nombreliterales); |
---|
88 | if(empty($Datos)) return(false); |
---|
89 | |
---|
90 | $idtipoaccion=$Datos["idcomando"]; |
---|
91 | $ambito=$Datos["ambito"]; |
---|
92 | $idambito=$Datos["idambito"]; |
---|
93 | $parametros=$Datos["parametros"]; |
---|
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 | ?> |
---|