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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| <?php
include('connection.php');
$q = mysql_query("SELECT * FROM cq_xml ORDER BY id_cq DESC limit 1;") or die('Erreur de la requête MySQL');
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\r\n";
while ($row = mysql_fetch_array($q)) {
$xml .= '<Endpoint UseAsQuery="'.$row["Query"].'">'."\r\n";
$xml .= '<Type>'.'CQ'.'</Type>'."\r\n";
$xml .= '<EpName>'.$row['Epname'].'</EpName>'."\r\n";
$xml .='<ConnectionData>'."\r\n";
$xml .= '<Username>'.$row['Username'].'</Username>'."\r\n";
$xml .= '<password encrypted="'.$row['radio'].'" value="'.$row['valeur'].'"/>'."\r\n";
$xml .= '<Properties>'."\r\n";
$xml .= '<property name="Repository" value="'.$row['database'].'"/>'."\r\n";
$xml .= '<property name="DataBase" value="'.$row['repository'].'"/>'."\r\n";
$xml .= '</Properties>'."\r\n";
$xml .= '</ConnectionData>'."\r\n";
$xml .= '<Filters>'."\r\n";
$xml .= '<operator name="'.$row['operator'].'" parent="'.$row['parent'].'" BoolOp="'.$row['boolop'].'"/>'."\r\n";
// ----
$array_filter_operator = explode('<br />',nl2br($row['filter_operator']));
$array_field = explode('<br />',nl2br($row['field']));
$array_compop = explode('<br />',nl2br($row['compop']));
$array_valeur_c = explode('<br />',nl2br($row['filter_operator']));
foreach($array_filter_operator as $key => $val) {
$xml .= '<filter operator="'.trim($array_filter_operator[$key]).'" field="'.trim($array_field[$key]).'" CompOp="'.trim($array_compop[$key]).'" value="'.trim($array_valeur_c[$key]).'"/>'."\r\n";
}
// ----
$xml .= '</Filters>'."\r\n";
$xml .= '<FieldToGet IDName="'.$row['Idname'].'">'."\r\n";
// ----
$array_field = explode('<br />',nl2br($row['Balises_field']));
foreach($array_field as $key => $val) {
$xml .= '<Field>'.trim($array_field[$key]).'</Field>'."\r\n";
}
// ----
$xml .= '</FieldsToGet>'."\r\n";
$xml .= '<PIMT server="'.$row['server'].'">'."\r\n";
$xml .= '<property name="password" value="'.$row['pass'].'"/>'."\r\n";
$xml .= '<property name="project" value="'.$row['Project'].'"/>'."\r\n";
$xml .= '<property name="group" value="'.$row['Group'].'"/>'."\r\n";
$xml .= '<property name="graph" value="'.$row['Graph'].'"/>'."\r\n";
$xml .= '<property name="description" value="'.$row['Description'].'"/>'."\r\n";
$xml .= '<property name="implicit" value="'.$row['Implicit'].'"/>'."\r\n";
$xml .= '<property name="date" value="'.$row['Date'].'"/>'."\r\n";
$xml .= '<property name="item" value="'.$row['Item'].'"/>'."\r\n";
$xml .= '<property name="states" value="'.$row['states'].'"/>'."\r\n";
$xml .= '</PIMT>'."\r\n";
} // fin while
$xml .= '</Endpoint>'."\r\n";
//if (feof($fichier))
$file = "D:/CQIET/wamp/www/projet_NDS/configuration/fichier_xml/".$fichier.".xml";
// $current= $xml;
//file_put_contents($file,$current);
// $f = 'exemple.txt';
//$text = "ma chaine de caractères";
$handle = fopen($file,"w+");
if (feof($file)) {
// regarde si le fichier est accessible en écriture
if (is_writable($file)) {
// Ecriture
if (fwrite($handle, $xml) === FALSE) {
echo 'Impossible d\'écrire dans le fichier '.$file.'';
exit;
}
echo 'Ecriture terminé';
fclose($handle);
}
else {
echo 'Impossible d\'écrire dans le fichier '.$file.'';
}
?>
<script language="javascript">
alert("enregister"); </script> <?php include("CQ_xml.php");exit;
echo 'Export XML effectue !<br><a href="carnetMysqlToXml.xml">Voir le fichier</a>'; |
Partager