static function probarXML($encodedXml)
 {
     $connect = xmlResponse::connect();
     if ($connect['result'] == 'fail') {
         return array('result' => __('Error de conexión'), 'message' => $connect['message']);
     } elseif ($connect['result'] == 'ok') {
         try {
             //_COMUNICACION_APD_
             $c1 = new Criteria();
             $c1->addAnd(ParametroPeer::TIPOPARAMETRO, "_COMUNICACION_APD_", Criteria::EQUAL);
             $parametro = ParametroPeer::doSelectOne($c1);
             if ($parametro->getSiNo()) {
                 $ejecutar = sfConfig::get('app_metodo_prueba_xml');
             } else {
                 $ejecutar = $ejecutar = sfConfig::get('app_metodo_registro_xml');
             }
             $res = xmlResponse::$client->__soapCall($ejecutar, array($encodedXml));
             //echo "\n\nRESPONSE1:\n" . xmlResponse::$client->__getLastResponse() . "\n";
             //echo "\n\nRESPONSE2:\n" . print_r($res) . "\n";
             return array('result' => 'ok', 'res' => $res, 'last' => xmlResponse::$client->__getLastResponse());
         } catch (SOAPFault $e) {
             return array('result' => __('Error de Soap'), 'message' => $e);
         }
     }
 }
Example #2
0
function signDocument()
{
    global $src_file, $target_file, $user_cert_file_path;
    // replace signature value with the signature made by card
    $src = file_get_contents($target_file);
    $src = preg_replace('/<ds:SignatureValue>[^<]*<\\/ds:SignatureValue>/i', '<ds:SignatureValue>' . $_POST['sinatuta'] . '</ds:SignatureValue>', $src);
    file_put_contents($target_file, $src);
    // send to service
    require_once 'xmlResponseProba.class.php';
    $xml = file_get_contents($target_file);
    $encodedXml = xmlResponse::encodeXML($xml);
    $aa = xmlResponse::probarXML($encodedXml);
    echo xmlResponse::decodeXML($aa['res']);
    echo "END";
}
    echo str_replace("\n", '<br />', str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", htmlentities(file_get_contents($dir))));
    ?>
            </div>
        </fieldset><?php 
    $encodedXml = xmlResponse::encodeXML($xml);
    $rEncodedXml = xmlResponse::probarXML($encodedXml);
    $res = '';
    ?>

        <fieldset>
            <label style="float:none; text-align:center; font-size: 12px" class="form1"><?php 
    if ($rEncodedXml['result'] != 'ok') {
        echo '<strong>' . $rEncodedXml['result'] . '</strong><br /><br />';
        echo '<u>' . __('Mensaje') . '</u>:<br />' . $rEncodedXml['message'] . '<br /><br />';
    } else {
        $res .= xmlResponse::decodeXML($rEncodedXml['res']);
    }
    if (strpos($res, '<est_err>00</est_err>') !== false) {
        $dir = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $id_fichero . '-' . $id_notificacion . '-result.xml';
        if (is_file($dir)) {
            unlink($dir);
        }
        file_put_contents($dir, utf8_decode($res));
        $date = substr(date('dmY'), 4, 4) . '-' . substr(date('dmY'), 2, 2) . '-' . substr(date('dmY'), 0, 2);
        $time = substr(date('His'), 0, 2) . ':' . substr(date('His'), 2, 2) . ':' . substr(date('His'), 4, 2);
        echo __('<strong>Resultado</strong> (fichero creado el %%fecha%% a las %%hora%%): %%dir%%', array('%%dir%%' => link_to($dir, $_SERVER["PHP_SELF"], array('id' => 'log2', 'class' => 'log')), '%%fecha%%' => format_date($date, "D", 'es'), '%%hora%%' => format_date($time, "t", 'es')), 'messages');
    } else {
        echo '<u id="log2" style="color: black; cursor: pointer" class="log">' . __('Resultado') . '</u>';
    }
    ?>
            </label>
Example #4
0
        header('Content-Type: text/xml');
        echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n";
        echo "<response>\n";
    }
    function command($method, $params = array(), $encoded = array())
    {
        echo "  <command method=\"{$method}\">\n";
        if ($params) {
            foreach ($params as $key => $val) {
                echo "    <{$key}>" . htmlspecialchars($val) . "</{$key}>\n";
            }
        }
        if ($encoded) {
            foreach ($encoded as $key => $val) {
                echo "    <{$key}><![CDATA[{$val}]]></{$key}>\n";
            }
        }
        echo "  </command>\n";
    }
    function end()
    {
        echo "</response>\n";
        exit;
    }
}
$retval = "output of PHP script";
$xml = new xmlResponse();
$xml->start();
$xml->command("setstyle", array("target" => "output", "property" => "display", "value" => "block"));
$xml->command("setcontent", array("target" => "samplecode"), array("content" => htmlentities($retval)));
$xml->end();