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
|
echo "<APPLET\n";
echo "CODEBASE=\"./applets\"";
echo "CODE=\"applet.init.AppletGraph\" WIDTH=100% HEIGHT=600\n";
echo "ARCHIVE=\"jcommon-1.0.16.jar, jfreechart-1.0.13.jar, jxl.jar, iText-5.0.1.jar, javacsv.jar, sAppletGraph.jar\">\n";
echo "<PARAM NAME=typeRep VALUE=\"".$_POST['typeRepGraphique']."\">\n";
echo "<PARAM NAME=parameter VALUE=\"".$parameter[$i]."\">\n";
echo "<PARAM NAME=sensor VALUE=\"".$sensorname[$i]."\">\n";
echo "<PARAM NAME=line VALUE=\"".$sensorline[$i]."\">\n";
echo "<PARAM NAME=floor VALUE=\"".$sensorfloor[$i]."\">\n";
//definition requete SQL
$select="select TO_CHAR(TS, 'YYYY-MM-DD HH24:MI:SS') as TS , ".$parameter[$i]." from ".$sensortable[$i]." where TS> to_date('".$_POST['dateFirst']."','DD/MM/YYYY HH24:MI:SS') and TS< to_date('".$_POST['dateLast']."','DD-MM-YYYY HH24:MI:SS') order by TS";
$reqSelect = oci_parse($connection, $select) or die('SQL Error ! <br/>'.$select.'<br/>');
oci_execute($reqSelect);
$string="";
$indice=0;
$flag=0;
//lecture ligne par ligne du resultat de la requete
//resultat sauvegardés sous la forme date%valeur
//données séparées par un @
//==> date%valeur@date%valeur@date%valeur ....
while ($rowSelect = oci_fetch_array($reqSelect, OCI_NUM+OCI_RETURN_NULLS)) {
$time=$rowSelect[0]; // TS
$value=$rowSelect[1]; // PARAMETER
if ($string == "") {
$string=$time."%".$value;
}
else {
//!!!! OPTIMISATION !!!!
//Le traitement des grandes chaines par PHP n'est pas optimale...
// => Limitation de la chaine à 100000 caractères
// string_[1], string_[2] ... qu'on concatène après
if (strlen($string) >= 100000) {
$string_[$indice]=$string;
$indice++;
$string=$time.'%'.$value;
}
else {
$string=$string.'@'.$time.'%'.$value;
}
}
$flag=1;
}
oci_free_statement($reqSelect);
//ajout derniers résultats dans le tableau
$string_[$indice]=$string;
//Concaténation
if($flag==1){
$string="";
for ($in=0;$in<=$indice;$in++) {
if ($string == "") { //début construction chaine
$string=$string_[$in];
}
else {
$string=$string.'@'.$string_[$in];
}
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//transmission à l'applet des données
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo "<PARAM NAME=\"valeur\" VALUE=\"".$string."\">\n";
}
else {
//rentre des valeurs bidons si lecture BDD pas fonctionnéé, flag==0
@list($jour,$mois,$annee)=explode('/',$_POST['dateFirst']);
$dateFirst=date('Y-m-d H:i:s',mktime(0,0,0,$mois,$jour,$annee));
@list($jour,$mois,$annee)=explode('/',$_POST['dateLast']);
$dateLast=date('Y-m-d H:i:s',mktime(0,0,0,$mois,$jour,$annee));
$string=$dateFirst."%0@".$dateLast."%0";
echo "<PARAM NAME=\"valeur\" VALUE=\"".$string."\">\n";
}
echo "</APPLET>\n"; |