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
|
#!/usr/bin/perl
use DBI;
use Asterisk::AGI;
my $AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $numero = $input{'callerid'};
my $code = sprintf("%d", int(rand(900000)+100000));
print "le code est $code\n";
$AGI->verbose("votre code confidentiel est le $code\n",1);
my $dbh = DBI->connect("DBI:mysql:asterisk","root","root");
my $verif = $dbh->prepare("select code from codes where code=$code");
$verif -> execute();
if ($code = $verif->fetchrow)
{
$AGI->set_priority(5);
}
else
{
my ($un, $deux, $trois, $quatre, $cinq, $six) = ($code =~ m/^(.)(.)(.)(.)(.)(.)/);
my @digits = split (//, $code);
print "le code est $digits[0],$digits[1],$digits[2],$digits[3],$digits[4],$digits[5]\n";
print "voici mon code : $un,$deux,$trois,$quatre,$cinq,$six\n";
$AGI->exec('Playback',"/usr/share/asterisk/sounds/digits/fr/$un");
$AGI->exec('Wait','1');
$AGI->exec('Playback',"/usr/share/asterisk/sounds/digits/fr/$deux");
$AGI->exec('Wait','1');
$AGI->exec('Playback',"/usr/share/asterisk/sounds/digits/fr/$trois");
$AGI->exec('Wait','1');
$AGI->exec('Playback',"/usr/share/asterisk/sounds/digits/fr/$quatre");
$AGI->exec('Wait','1');
$AGI->exec('Playback',"/usr/share/asterisk/sounds/digits/fr/$cinq");
$AGI->exec('Wait','1');
$AGI->exec('Playback',"/usr/share/asterisk/sounds/digits/fr/$six");
$AGI->exec('Wait','1'); |
Partager