コード例 #1
0
ファイル: test.php プロジェクト: Veridata/catalogoVFarma
function test($param)
{
    $respuestaError = new respuestaError();
    if (DEBUG & DEBUG_LOG) {
        $mensaje = print_r($param, TRUE);
        $mensaje .= "--Llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
        error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
    }
    return array("testResult" => array("version" => VERSION, "datosEmpresa" => "(Farmacia:" . $param->farmacia . "), (DNI:" . $param->DNIFarmacia . "), (Certificado:" . $_SERVER['CERT_SUBJECT'] . ")", "resultadoOperacion" => $respuestaError->sinErrores()));
}
コード例 #2
0
/**
 *
 * @param resource $conn
 *        	Recurso que contiene la conexión SQL.
 * @param string $tabla        	
 * @return array Error SQL si lo hay, NULL si todo correcto.
 */
function crearTablaAudi($conn, $tabla)
{
    global $farmacia;
    $respError = new respuestaError();
    $sql = "CREATE TABLE {$tabla} (\n\t\tid int IDENTITY (1, 1) NOT NULL,\n\t\tCN varchar (300) NULL,\n\t\tnumeroFarmacia char (10) NULL,\n\t\tfechaHora datetime NULL,\n\t\tpreguntaSOAP text NULL,\n\t\ttiempoRespuesta int NULL,\n\t\ttipoPeticion varchar (50) NULL,\n\t\tversion char (8) NUll,\n\t\tnombreServidor varchar (100) NULL\n\t\tCONSTRAINT [PK_{$tabla}] PRIMARY KEY  CLUSTERED([ID])  ON [PRIMARY])\n\t\tALTER TABLE [dbo].[{$tabla}] ADD  CONSTRAINT [DF_" . $tabla . "_fechaHora]  DEFAULT (getdate()) FOR [fechaHora]";
    $stmt = sqlsrv_query($conn, $sql);
    if ($stmt === false) {
        if (($errors = sqlsrv_errors()) != null) {
            $SQLSTATE = $errors[0]["SQLSTATE"];
            $Cerror = $errors[0]["code"];
            $Merror = utf8_encode($errors[0]["message"]);
            if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
                if (DEBUG & DEBUG_ERROR_SQL) {
                    $mensaje = "--[" . date("c") . "] Farmacia: {$farmacia} código: {$Cerror} mensaje: {$Merror} \n";
                    $mensaje .= "--Error en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
                    error_log($mensaje . $sql . "\r\n", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
                }
            }
            return $respError->errorSQL($SQLSTATE, $Cerror, $Merror, $tipoPeticion, $farmacia);
        }
    }
    return null;
}
コード例 #3
0
/**
 *
 * @param resource $conn
 *        	Recurso que contiene la conexión SQL.
 * @param string $tabla        	
 * @return array Error SQL si lo hay, NULL si todo correcto.
 */
function crearTablaDis($conn, $tabla)
{
    global $farmacia;
    $respError = new respuestaError();
    $sql = "CREATE TABLE [dbo].[{$tabla}](\r\n\t\t\t[idReceta] [int] IDENTITY(1,1) NOT NULL,\r\n\t\t\t[farmacia] [varchar](10) NULL,\r\n\t\t\t[idDispensable] [int] NULL,\r\n\t\t\t[codigoNacionalPrescrito] [varchar](7) NULL,\r\n\t\t\t[codigoNacional] [varchar](7) NULL,\r\n\t\t\t[envases] [int] NULL,\r\n\t\t\t[dni] [varchar](50) NULL,\r\n\t\t\t[contenido] [varchar](50) NULL,\r\n\t\t\t[pvpComer] [money] NULL,\r\n\t\t\t[pvpCalculado] [money] NULL,\r\n\t\t\t[aportacionProducto] [int] NULL,\r\n\t\t\t[codigoAportacion] [varchar](50) NULL,\r\n\t\t\t[idActoDispensacion] [int] NULL,\r\n\t\t\t[idDispensacion] [int] NULL,\r\n\t\t\t[farmaceutico] [varchar](12) NULL,\r\n\t\t\t[fechaGrabacion] [datetime] NULL,\r\n\t\t\t[fechaAnulacion] [datetime] NULL,\r\n\t\t\t[fechaFirma] [datetime] NULL,\r\n\t\t\t[origen] [varchar](25) NULL,\r\n\t\t\t[firma] [text] NULL,\r\n\t\t\t[firmaFacturacion] [text] NULL,\r\n\t\t\t[validado] [char](1) NOT NULL,\r\n\t\t\t[firmado] [char](1) NOT NULL,\r\n\t\t\t[borrado] [char](1) NOT NULL\r\n\t) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]\r\n\tALTER TABLE [dbo].[{$tabla}] ADD  CONSTRAINT [DF_" . $tabla . "_fechaGrabacion]  DEFAULT (getdate()) FOR [fechaGrabacion]\r\n\tALTER TABLE [dbo].[{$tabla}] ADD  DEFAULT ('1') FOR [validado]\r\n\tALTER TABLE [dbo].[{$tabla}] ADD  DEFAULT ('0') FOR [firmado]\r\n\tALTER TABLE [dbo].[{$tabla}] ADD  DEFAULT ('0') FOR [borrado]";
    $stmt = sqlsrv_query($conn, $sql);
    if ($stmt === false) {
        if (($errors = sqlsrv_errors()) != null) {
            $SQLSTATE = $errors[0]["SQLSTATE"];
            $Cerror = $errors[0]["code"];
            $Merror = utf8_encode($errors[0]["message"]);
            if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
                if (DEBUG & DEBUG_ERROR_SQL) {
                    $mensaje = "--[" . date("c") . "] Farmacia: {$farmacia} código: {$Cerror} mensaje: {$Merror} \n";
                    $mensaje .= "--Error en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
                    error_log($mensaje . $sql . "\r\n", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
                }
            }
            return $respError->errorSQL($SQLSTATE, $Cerror, $Merror, $tipoPeticion, $farmacia);
        }
    }
    return null;
}
コード例 #4
0
ファイル: crearTablaDis.php プロジェクト: Veridata/SISCATA
/**
 *
 * @param resource $conn
 *        	Recurso que contiene la conexión SQL.
 * @param string $tabla        	
 * @return array Error SQL si lo hay, NULL si todo correcto.
 */
function crearTablaDis($conn, $tabla)
{
    global $farmacia;
    $respError = new respuestaError();
    $sql = "CREATE TABLE [dbo].[{$tabla}](\n\t\t\t\t[id] [int] IDENTITY(1,1) NOT NULL,\n\t\t\t\t[farmacia] [varchar](10) NULL,\n\t\t\t\t[sistema] [varchar](10) NULL,\n\t\t\t\t[idtx] [varchar](20) NULL,\n\t\t\t\t[CIP] [varchar](20) NULL,\n\t\t\t\t[identificacion] [varchar](250) NULL,\n\t\t\t\t[DNI] [varchar](15) NULL,\n\t\t\t\t[codfarmacia] [varchar](10) NULL,\n\t\t\t\t[codColegiado] [varchar](15) NULL,\n\t\t\t\t[numColegiado] [varchar](15) NULL,\n\t\t\t\t[TSI] [varchar](15) NULL,\n\t\t\t\t[id_Receta] [varchar](25) NULL,\n\t\t\t\t[PVPCalculadoAport] [money] NULL,\n\t\t\t\t[PVPTotal] [money] NULL,\n\t\t\t\t[euros_Receta] [varchar](4) NULL,\n\t\t\t\t[envases] [int] NULL,\n\t\t\t\t[codNacional] [varchar](8) NULL,\n\t\t\t\t[PVPComerEnv] [money] NULL,\n\t\t\t\t[aportacionProducto] [float] NULL,\n\t\t\t\t[check_Atep] [varchar](4) NULL,\n\t\t\t\t[indicador_Euro] [varchar](4) NULL,\n\t\t\t\t[check_Objecion] [varchar](4) NULL,\n\t\t\t\t[check_Visado] [varchar](4) NULL,\n\t\t\t\t[fechaXML] [varchar](25) NULL,\n\t\t\t\t[fechaGrabacion] [datetime] NULL,\n\t\t\t CONSTRAINT [PK_{$tabla}] PRIMARY KEY CLUSTERED \n\t\t\t\t(\n\t\t\t\t\t[id] ASC\n\t\t\t\t)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]\n\t\t\t\t\t\t) ON [PRIMARY]\n\tALTER TABLE [dbo].[{$tabla}] ADD  CONSTRAINT [DF_" . $tabla . "_fechaGrabacion]  DEFAULT (getdate()) FOR [fechaGrabacion]";
    $stmt = sqlsrv_query($conn, $sql);
    if ($stmt === false) {
        if (($errors = sqlsrv_errors()) != null) {
            $SQLSTATE = $errors[0]["SQLSTATE"];
            $Cerror = $errors[0]["code"];
            $Merror = utf8_encode($errors[0]["message"]);
            if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
                if (DEBUG & DEBUG_ERROR_SQL) {
                    $mensaje = "--[" . date("c") . "] Farmacia: {$farmacia} código: {$Cerror} mensaje: {$Merror} \n";
                    $mensaje .= "--Error en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
                    error_log($mensaje . $sql . "\r\n", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
                }
            }
            return $respError->errorSQL($SQLSTATE, $Cerror, $Merror, $tipoPeticion, $farmacia);
        }
    }
    return null;
}
コード例 #5
0
/**
 * Valida un el body de un mensaje soap contra el esquema XSD.
 * 
 * @param string $funcion
 *        	es el nombre del metodo que queremos validar.<br> Normalmente es
 *        	la constante __FUNCTION__ para validar el "request".
 * @return multitype array si hay un error y NULL en cualaquier otro caso.
 */
function validarMensajeXML($funcion)
{
    if (!isset($HTTP_RAW_POST_DATA)) {
        $HTTP_RAW_POST_DATA = implode("\r\n", file('php://input'));
    }
    $respError = new respuestaError();
    $domRequest = new DOMDocument();
    $domRequest->loadXML($HTTP_RAW_POST_DATA);
    /*$body = $domRequest->getElementsByTagName($funcion);
    	 //die(print_r($domRequest->saveXML($body->item("0"))));
    	 $domRequest->loadXML($domRequest->saveXML($body->item("0")));
    	 $domRequest->createAttributeNS("http://www.proyectomadre.es/catalogoServicios", "xmlns");
    	 $domRequest->loadXML($domRequest->saveXML());*/
    libxml_use_internal_errors(true);
    if (!$domRequest->schemaValidate(NOMBRE_WEB_SERVICE . ".xsd")) {
        $errors = libxml_get_errors();
        //die(print_r($errors));
        libxml_clear_errors();
        libxml_use_internal_errors(false);
        return $respError->errorValidacion($errors[0]->code, $errors[0]->message, $funcion);
    } else {
        return NULL;
    }
}
コード例 #6
0
ファイル: SISCATA.php プロジェクト: Veridata/SISCATA
/**
 * Servidor SOAP del Colegio Oficial .
 * 
 * @author Mario Contreras García
 * @author Guillermo Gallego Gallego
 * @copyright Veridata s.l. 2015
 */
use_soap_error_handler(true);
// Definimos constantes de depuración
define("DEBUG_LOG", 1);
define("DEBUG_ERROR_SQL", 2);
define("DEBUG_QUERY", 4);
define("DEBUG_TIEMPO", 8);
require_once "include/funciones.php";
$respError = new respuestaError();
$entorno = "test";
if (stripos($_SERVER["SCRIPT_FILENAME"], "pro")) {
    $entorno = "pro";
}
define("ENTORNO", $entorno);
define("NOMBRE_WEB_SERVICE", basename(__FILE__, ".php"));
define("WSDL", NOMBRE_WEB_SERVICE . ".wsdl");
$fcheroINI = NOMBRE_WEB_SERVICE . ".ini";
if (file_exists($fcheroINI) && is_readable($fcheroINI)) {
    $settings = parse_ini_file($fcheroINI, true);
} else {
    throw new SoapFault("Server.0", "Error, el fichero {$fcheroINI} no existe o no se puede abrir para lectura.");
    /*$soapResponse = $respError->SOAPFault("Server.0", "Error, el fichero $fcheroINI no existe o no se puede abrir para lectura.");
    	 print $soapResponse;
    	 exit();*/
コード例 #7
0
/**
 * Inserta un registro en la tabla de auditoría, si no existe la tabla la crea.
 * Si hay algún error al insertar, crea un fichero log_error.
 * 
 * @param resource $conn
 *        	Recurso que contiene la conexión SQL
 * @param int $farmacia
 *        	Número de farmacia con cuatro dígitos.
 * @param string $pregunta
 *        	Texto request o response a auditar.
 * @param string $tipoPeticion
 *        	Nombre del método que se va a auditar.
 * @param int $tiempoRespuesta
 *        	En el caso que sea una respuesta, el cálculo del tiempo
 *        	transcurrido entre la petición y la respuesta.
 * @return array Error SQL si lo hay, NULL si todo correcto.
 */
function auditar($conn, $farmacia, $pregunta, $tipoPeticion, $tiempoRespuesta = 0)
{
    $pregunta = cambiarComilla(utf8_decode($pregunta));
    $respError = new respuestaError();
    /*require_once 'include/chilkat_9_5_0.php';
    	 $gzip = new CkGzip();
    	 
    	 $success = $gzip->UnlockComponent('ANTONIZIP_C45PQWhK4Pwf');
    	 if ($success != true) {
    	 print $gzip->lastErrorText() . "\n";
    	 exit();
    	 }
    	 //print strlen(base64_encode($pregunta)) . "\n";
    	 //print $pregunta . "\n";
    	 //$preguntaArray = new CkByteData();
    	 //$preguntaArray->appendStr($pregunta);
    	 //$gzip->CompressString($pregunta, "UTF-8", $preguntaArray);
    	 //print $preguntaArray->getSize() . "\n";
    	 //$pregunta2 = $gzip->CompressStringENC($pregunta);
    	 //$pregunta2 = $gzip->uncompressStringENC(base64_encode($pregunta));
    	 //print $pregunta2 . "\n";*/
    //TODO poner en la auditoría de Dephi el deflate para poder ver los resultados, mientras no este hecho hay que dejarlo comentado
    //$pregunta = zlib_encode($pregunta, ZLIB_ENCODING_GZIP);
    //$pregunta = gzcompress($pregunta, 9);
    //$pregunta = gzdeflate($pregunta, 9); // El que más comprime. Este funciona.
    //$pregunta = gzencode($pregunta, 9); // El que menos comprime.
    $tabla = PREFIJO_TABLA_AUDITORIA . date("ym");
    if (!($existeTabla = existeTabla($conn, $tabla, COMPOROBAR_TABLA))) {
        // La tabla no existe
        if ($crearTablaAudi = crearTablaAudi($conn, $tabla) != null) {
            return $crearTablaAudi;
        }
    }
    $CN = CN . " SERIALNUMBER: " . $_SERVER["CERT_SERIALNUMBER"];
    $tiempoRespuesta = intval($tiempoRespuesta);
    $parametros = array($CN, $farmacia, base64_encode($pregunta), $tipoPeticion, $tiempoRespuesta, VERSION, $_SERVER["COMPUTERNAME"]);
    $sql = "insert into {$tabla}\n\t\t(CN\n\t\t,numeroFarmacia\n\t\t,preguntaSOAP\n\t\t,tipoPeticion\n\t\t,tiempoRespuesta\n\t\t,version\n\t\t,nombreServidor)\n\tvalues\n\t\t(?\n\t\t,?\n\t\t,?\n\t\t,?\n\t\t,?\n\t\t,?\n\t\t,?)";
    // Insertar el registro en la tabla
    //////////////////////////////////////////////////////
    if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0 or $farmacia == "err") {
        if (DEBUG & DEBUG_QUERY) {
            $mensaje = "--[" . date("c") . "] Farmacia: {$farmacia} \n";
            $mensaje .= "--Query hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__ . "\n";
            error_log($mensaje . verQuery($sql, $parametros) . "\r\n", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
        }
    }
    $stmt = sqlsrv_query($conn, $sql, $parametros);
    if ($stmt === false) {
        if (($errors = sqlsrv_errors()) != null) {
            $SQLSTATE = $errors[0]["SQLSTATE"];
            $Cerror = $errors[0]["code"];
            $Merror = utf8_encode($errors[0]["message"]);
            if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0 or $farmacia == "err") {
                if (DEBUG & DEBUG_ERROR_SQL) {
                    $mensaje = "--[" . date("c") . "] Farmacia: {$farmacia} código: {$Cerror} mensaje: {$Merror}" . "\n";
                    $mensaje .= "--Error en el fichero: " . __FILE__ . ", en la línea: " . __LINE__ . "\n";
                    error_log($mensaje . verQuery($sql, $parametros) . "\r\n", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
                }
            }
            sqlsrv_close($conn);
            return $respError->errorSQL($SQLSTATE, $Cerror, $Merror, $tipoPeticion, $farmacia);
        }
    }
    // Salir con el valor de resultado a NULL
    //////////////////////////////////////////////////////
    sqlsrv_free_stmt($stmt);
    //return $respError->errorSQL("SQLSTATE", "Cerror", "Merror", $tipoPeticion, $farmacia);
    return NULL;
}