Skip to content
Snippets Groups Projects
ws_client.php 1.29 KiB
Newer Older
  • Learn to ignore specific revisions
  • <?php 
    require('SOAP/Client.php');
    
    $proxy = array('user' => $_REQUEST['proxy1'], 'pass' => $_REQUEST['proxy2'], 'timeout' => '600');
    
    $wsdl = new SOAP_WSDL('http://127.0.0.1/maarch_entreprise/ws_server.php?WSDL', $proxy, false);
    $client = $wsdl->getProxy();
    /*************** view Maarch document *********************/
    $fileContentArray = array();
    $fileContentArray = $client->viewResource((integer) $_REQUEST['id'], $_REQUEST['table']);
    if($fileContentArray->status == "ok") {
    
        $fileContent = base64_decode($fileContentArray->file_content);
    
    Giovannoni Laurent's avatar
    Giovannoni Laurent committed
        $Fnm = $fileContentArray->tmp_path . DIRECTORY_SEPARATOR . rand() 
             . "_" . md5($fileContent) . "." . strtolower($fileContentArray->ext);
    
        $inF = fopen($Fnm, "w");
        fwrite($inF, $fileContent);
        fclose($inF);
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Type: ".strtolower($fileContentArray->mime_type));
    
    Giovannoni Laurent's avatar
    Giovannoni Laurent committed
        header("Content-Disposition: inline; filename=" 
            . basename('maarch.' . strtolower($fileContentArray->ext)) . ";"
        );
    
        header("Content-Transfer-Encoding: binary");
        readfile($Fnm);
        exit();
    
        echo $fileContentArray->error;