1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <?php
session_start();
include ('config.php');
$id=@$_GET['id'];
header("Content-Type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
$result_table= mysql_query("SELECT * FROM tablewhere id='$id'");
$num_table = mysql_num_rows($result_table);
if ($num_table != 0) {
while ($row = mysql_fetch_array($result_table)) {
$file= fopen("export_$row[nom_e]_$row[prenom_e]_$row[id].xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$_xml .="";
$_xml .="<DOSSIER>
..... toutes les balises ....
</DOSSIER>";
echo '<html>
<head>
</head>
<body>
<a href="http://'. $url_index.'/export_'.$row["nom_e"].'_'.$row["prenom_e"].'_'.$row["id"].'.xml" target="_blank"> Voir fichier xml </a>
';
$nom_xml=$row["nom_e"].'_'.$row["prenom_e"].'_'.$row["id"];
// $_xml .="header('Content-Type: text/xml')";
}
// echo $_xml;
fwrite($file, $_xml);
fclose($file);
/*
* XML Sender/Client.
*/
$file = 'http://'. $url_index.'/export_'.$nom_xml.'.xml';
if(!$xml_builder = simplexml_load_file($file))
exit('Failed to open '.$file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://urlduserveur");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_REFERER, 'https://urlduserveur');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ch_result = curl_exec($ch);
curl_close($ch);
// Print CURL result.
echo $ch_result;
}
echo '</body></html>';
?> |
Partager