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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
set_time_limit(0);
global $dbr,$id,$OR,$i,$j,$k,$x,$y,$z,$stat,$withdemo,$withoutdemo,$chi,$cr,$a,$b,$cnx,$db,$sql;
$a=0;
$b=0;
$x=0;
$y=0;
$z=0;
$fichier = "hegpAllMeasuresNewChi2.lat.xml";
function fonctionBaliseOuvrante($parseur, $nomBalise,$attribut) {
global $dbr,$id,$OR,$i,$j,$k,$x,$y,$z,$stat,$withdemo,$withoutdemo,$chi,$cr,$a,$b;
$dbr = $nomBalise;
if($dbr=="CONCEPT"){
$id="";$OR="";$i="";$j="";$k="";$x=0;$y=0;$z=0;$stat="";$withdemo="";$withoutdemo="";$chi="";$cr="";$a=0;$b=0;}
}
function fonctionBaliseFermante($parseur, $nomBalise){
global $dbr,$id,$OR,$i,$j,$k,$x,$y,$z,$stat,$withdemo,$withoutdemo,$chi,$cr,$a,$b,$cnx,$db,$sql;
if($nomBalise=="CONCEPT_REF"){
$a=$a+1;}
if($nomBalise=="OBJECT_REF"){
$b=$b+1;}
if($nomBalise=="CONCEPT"){
$cnx = mysql_connect( "localhost", "root", "" ) ;
$db = mysql_select_db("greg");
$sql="INSERT INTO concepts (id, nbextension, extension, nbintei, intei, nbintmed, intmed, nbintdemo, intdemo, nbflatintei, flatintei, nbflatintmed, flatintmed, nbflatintdemo, flatintdemo, nbcover,cover, prrdemo, prrssdemo, chi, stab, type, comment, valid, xml) VALUES ('$id','$b','$OR','$z','$i','$y','$j','$x','$k','','','','','','','$a','$cr','$withdemo','$withoutdemo','$chi','$stat','','','','')";
$sql2="INSERT INTO extension (id,obj) VALUES ('$id','$OR')";
$sql3="INSERT INTO intdemo (id,att) VALUES ('$id','$k')";
$sql4="INSERT INTO intei (id,att) VALUES ('$id','$i')";
$sql5="INSERT INTO intmed (id,att) VALUES ('$id','$j')";
$sql6="INSERT INTO upcover (id,upcover) VALUES ('$id','$cr')";
$requete = mysql_query( $sql, $cnx ) or die( mysql_error() ) ;
$requete1 = mysql_query( $sql2, $cnx ) or die( mysql_error() ) ;
$requete2 = mysql_query( $sql3, $cnx ) or die( mysql_error() ) ;
$requete3 = mysql_query( $sql4, $cnx ) or die( mysql_error() ) ;
$requete4 = mysql_query( $sql5, $cnx ) or die( mysql_error() ) ;
$requete5 = mysql_query( $sql6, $cnx ) or die( mysql_error() ) ;
mysql_close($cnx); }
$dbr= "";
}
function fonctionTexte($parseur, $text){
global $dbr,$id,$OR,$i,$j,$k,$x,$y,$z,$stat,$withdemo,$withoutdemo,$chi,$cr;
if($dbr=="ID"){$id=$text;}
if($dbr=="OBJECT_REF"){$OR=$text." ".$OR;}
if (substr($text, 0, 2)=="1-"){
$i=$text." ".$i;
$i=addslashes($i);
$z=$z+1;}
if (substr($text, 0, 2)=="2-"){
$j=$text." ".$j;
$j=addslashes($j);
$y=$y+1;}
if (substr($text, 0, 2)=="3-"){
$k=$text." ".$k;
$k=addslashes($k);
$x=$x+1;}
if($dbr=="STABILITY"){$stat=$text;}
if($dbr=="PRRWITHDEMO"){$withdemo=$text;}
if($dbr=="PRRWITHOUTDEMO"){$withoutdemo=$text;}
if($dbr=="CHI2"){$chi=$text;}
if($dbr=="CONCEPT_REF"){$cr=$text." ".$cr;}
}
$parseurXML = xml_parser_create();
xml_set_element_handler($parseurXML, "fonctionBaliseOuvrante", "fonctionBaliseFermante");
xml_set_character_data_handler($parseurXML, "fonctionTexte");
// Ouverture du fichier
$fp = fopen($fichier, "r");
if (!$fp) die("Impossible d'ouvrir le fichier XML");
while ( $ligneXML =fread($fp,50)){
xml_parse($parseurXML, $ligneXML, feof($fp)) or die("Erreur XML");
}
fclose($fp);
xml_parser_free($parseurXML);
echo 'la base est cool';
?> |
Partager