#!/usr/bin/perl -w use Asterisk::AMI; use CGI qw/:standard/; require ('/etc/callback/callback.conf'); $host ||= '127.0.0.1'; $port ||= '5038'; $user ||= 'callback'; $secret ||= 'secret'; my $q = new CGI; print $q->header, $q->start_html(-title=>'CallBack', ), $q->h1('page de callback'), $q->start_form, "Entrez ici votre numero ",textfield('nback'),p, "Entrez ici le numero de votre destinataire ", textfield('ndest'),p, $q->submit, $q->end_form, $q->hr; if ($q->param()) { my $nback = $q->param('nback') || $ENV{'HTTP_USER_EXTENSION'}; my $ndest = $q->param('ndest'); $nback =~ s/[\s\(\)\.<>]//g; $ndest =~ s/[\s\(\)\.<>]//g; unless (($nback =~ m/^\d+$/) && ($ndest =~ m/^\d+$/)){ print $q->h1('un des numeros ne semble pas valide, ils ne doivent contenir que des chiffres'); die ('bad number'); } my $astman = Asterisk::AMI->new(PeerAddr => "$host", PeerPort => "$port", Username => "$user", Secret => "$secret" ); die "Unable to connect to asterisk" unless ($astman); my $response = $astman->action({Action => 'Originate', Channel => "Local/$nback\@from-internal", Context => 'from-internal', CallerID => $ndest, Exten => $ndest, Priority => 1}); }