#!/usr/bin/perl
require "variable.pl";
$access = "";
print "Content-type: text/html\n\n";
if ($ENV {'REQUEST_METHOD'} eq 'GET')
{
print <<"FINI";
The ElectroChemical DataBase
$HEADER
ElectroChemical DataBase
Gibbs Energies of transfer
Search EDB:
You can search EDB with the following form. If you write multiples words in a field, the program will interpret it as a logical AND. Please do not put logical words (OR, XOR, AND, NOT) in the fields. You can give only parts of words. That means that a search with keyword "ium" will find Calcium or potassium.
Note that the "ion" field is searchable with complete names (Potassium) and with chemical symbols (K), at least for the simple ions. You can even search for a given charge (++ for a doubly charged cation, for example).
To print the whole DataBase, please do not write anything in the keywords fields, and let the "maximum answer" be "Infinite".
Addition:
We're adding everyday new datas in the DataBase. But we would be very thankful if you would help us to complete it. If you've some interesting new datas, please communicate them to us using the following form:
Add a record in EDB. Username: pass, Password: pass
FINI
}
if ($ENV {'REQUEST_METHOD'} eq 'POST')
{
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
#print"$buffer\n\n";
@pairs=split(/&/,$buffer);
foreach $pair (@pairs)
{
($name, $value)=split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$CONTENTS{$name}=$value;
#print"$name:$value\n";
}
#Champs caracteristiques
$nom=$CONTENTS{"nom"};
@nom=split(/ /,$nom);
$solvant=$CONTENTS{"solvant"};
$valeur=$CONTENTS{"valeur"};
$hyp=$CONTENTS{"hyp"};
$comments=$CONTENTS{"comments"};
@comments=split(/ /,$comments);
#nombre de reponses a donner
$num=$CONTENTS{"max_rep"};
#Type: hidden
$data=$CONTENTS{"fich"};
if ($num eq "5")
{
$nombre = 5;
}
elsif ($num eq "10")
{
$nombre = 10;
}
elsif ($num eq "50")
{
$nombre = 50;
}
else
{
$nombre = 10000;
}
print "\n\nElectrochemical DataBase";
print "\n";
print "";
print $HEADER;
open(FILE, "EDB_nb.DAT");
$Cnt = ;
close(FILE);
print "
Query Results
";
print "
Search #$Cnt
";
$Cnt = $Cnt + 1;
open(FILE, ">EDB_nb.DAT");
# print FILE "$ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'})\n";
print FILE "$Cnt\n";
close FILE;
print "
The Query contained the following keys:
";
print "\tMolecule/Ion: ";
foreach $nomp (@nom)
{
print "$nomp ";
}
print "
";
print "\tSolvent: ";
print "$solvant ";
print "
";
print "\tGibbs Energy: $valeur
";
print "\tHypothesis: ";
print "
";
print "\tComments: ";
print "
";
print "\tFile: $data
";
&print_matching_entries($nom,$solvant,$valeur,$hyp,$comments);
print "
\n";
print "\n";
print "
\n\n";
print "
Page Manager:
";
print "
";
print "";
}
sub print_matching_entries
{
local($s_nom,$s_solvant,$s_valeur,$s_hyp,$s_comments)=@_;
$boulou=0;
$count=0;
SEARCH: ($ba, $bb, $bc, $bd, $be, $bf, $bg, $bh, $bi) = localtime($j);
$be = $be + 1;
open(FILE,"$data") || print "\n\n\nerr #36:
\n\n ";
print"
Ion | Solvent | Gibbs Energies [KJ/mol] | References | Comments";
$KOKO=1;
@CHim=;
@Sorted = sort @CHim;
foreach $reco (@Sorted)
{
chop;
($nom1,$nom2,$nom3,$g_solvant,$g_value,$g_hyp,$g_comments)=split("\t",$reco);
@s_nom=split(/ /,$s_nom);
foreach $t_nom (@s_nom)
{
goto SUITE unless ($t_nom eq "" || $nom1 =~ /$t_nom/i || $nom2 =~ /$t_nom/i || $nom3 =~ /$t_nom/i);
}
next unless ($s_value eq "" || $g_value =~ /$s_value/i);
next unless ($s_solvant eq "" || $g_solvant =~ /$s_solvant/i);
next unless ($s_date eq "" || $date =~ /$s_date/i);
next unless ($s_hyp eq "" || $g_hyp =~ /$s_hyp/i);
@s_nom=split(/ /,$s_nom);
foreach $t_comments (@s_comments)
{
goto SUITE unless ($t_comments eq "" || $g_comments =~ /$t_comments/i);
}
$count++;
if ($count <= $nombre)
{
print"";
print"$nom1 $nom2 $nom3";
print" | $g_solvant";
print" | $g_value";
print" | $g_hyp";
print" | $g_comments";
@REF[$KOKO]=$g_hyp;
$KOKO+=1;
}
SUITE: $coin=0;
}
close(FILE) || print "\n\n\nerr #44: \n\n\n";
print" | |
";
open(FILE, "Electr_Chem_RF.DAT") || print "\n\n\nerr #36:
\n\n ";
print"";
@bonga=;
foreach $bonga (@bonga) {
chop($bonga);
($rtu, $rtz, $yr)=split("\t", $bonga);
foreach $red (@REF) {
if ($red ne "" && $rtz eq $red) {$coin=1;}
}
if ($coin == 1)
{
($rtu, $rtz, $yr)=split("\t", $bonga);
print"$rtz\t$yr\n";
}
$coin=0;
}
print"
";
close(FILE) || print "\n\n\nerr #44:
\n\n\n";
if ($count < 1) {
print"\n\nSorry, No Hits";
} elsif ($count > $nombre) {
print "\n\nThe $nombre first datas corresponding to your request";
print " were printed.\n\n";
} else {
print "\n\n$count datas corresponds to your";
print " request.\n\n";
}
}
#mode: Perl
#END: