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
| #!/usr/bin/perl
use DBI;
use Asterisk::AGI;
use strict;
my $AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
#Connexion à la base de données
my $dbh = DBI->connect("DBI:mysql:dbname=note;host=localhost","root","passer" ) or die "$DBI::errstr()";
#Appel au synthétiseur vocale
if ($code == '') {
print "EXEC LIAMBROLA \"Entrez votre code serveur:\n");
$agi->exec("read", "code");
#Récupération du choix saisie par l'appelant
#$code = $agi->get_variable("code");
$code = $agi->get_data('/var/lib/asterisk/sounds/beep',100000000,4);
my $verif = $dbh->prepare("select codeserver from etudiant where codeserver=$code" ) or die "$dbh->errtsr()";
$verif -> execute() or die "$verif->errstr()";
#$code = $verif->fetchrow();
if ($code = $verif ->fetchrow)
{
my $listmat = $dbh->prepare("select matiere from matiere") or die "$dbh->errtsr()";
$listmat -> execute() or die "$listmat->errstr()";
my $matiere = $listmat->fetchrow_array;
$listmat->finish();
}
else
{
$AGI -> exec('Playback','/var/lib/asterisk/sounds/fr/conf-errormenu');
}
}
#Liste des matieres
print "EXEC LIAMBROLA \"Tapez 1 $matiere[0] Tapez 2 $matiere[1] Tapez 3 $matiere[2],any\"\n";
if ($code_mat == '')
{
$agi->exec("read", "code");
$code_mat = get_variable("code_mat");
#my $code_mat = $AGI->get_data("/var/lib/asterisk/sounds/beep",10000000000,10);
#Exécution de la requête SQL
my $verifi = $dbh->prepare("select matiere from matiere where matiere.codeclasse='$code_mat'") or die "$dbh->errstr()";
$verifi->execute() or die "$verifi->errstr()";
my $matiere = $verifi->fetchrow();
$verifi->finish();
}
#Type de note
$requete = "select typenote from note";
my $sth = $dbh->prepare($requete) or die "$dbh->errstr()";
$sth->execute();
my $type = $sth->fetchrow_array();
$sth->finish();
#Affiche note
print "EXEC LIAMBROLA \"Tapez 1 $type[0] Tapez 2 $type[1] Tapez 3 $type[2],any\"\n";
$AGI->exec("read", "typenote");
$typenote = get_variable("typenote");
my $requet = $dbh->("select note from note where note.type_note='$typenote'") or die "$dbh->errstr()";
$requet->execute() or die "$reque->errstr()";
my $note = $requet->fecthrow_hash();
my $i = $note->fetchrow_array;
$AGI->say_number($i);
$AGI->verbose($AGI->channel_status);
if($AGI->channel_status == "User disconnected") {
$AGI->hangup();
}
//Fermeture de la connexion
$dbh->disconnect();
//raccrochage
$AGI->hangup(); |
Partager