<?php

if (!isset($_POST['filesent'])) {
    include 
'upload.html';
} else {
    
$contents file_get_contents($_FILES['xmlfile']['tmp_name']);
    
$request =  'http://localhost/validate/';

    
$header[] = "Content-type: text/xml";
    
$header[] = "Content-length: ".strlen($contents);
    
$header[] = "Content-language: en";
    
$header[] = "Cache-Control: no-cache";
    
$header[] = "Connection: close \r\n";
    
$header[] = $contents;
    
    
$ch curl_init();
    
curl_setopt($chCURLOPT_URL$request);
    
//curl_setopt($ch, CURLOPT_HEADER, 1); 
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_TIMEOUT4);
    
curl_setopt($chCURLOPT_CUSTOMREQUEST'POST');
    
curl_setopt($chCURLOPT_HTTPHEADER$header);

    
$result curl_exec($ch);

    
$theXML DOMDocument::loadXML($result);
    
$theXSL DOMDocument::load('transform.xsl');

    
$xslt = new XSLTProcessor();
    
$xslt->importStylesheet($theXSL);    
    
$output $xslt->transformToXML($theXML);
    
    if (
$output) {
        echo 
$output;
    } else {
        echo 
"Sorry, an error occured!"
    }
}    

?>