#!/usr/bin/perl use Frontier::Client; use Data::Dumper; use CGI; use LWP::UserAgent; # Things worth changing ############################################################################################### my $server_url = 'http://freeswitch1:disasterisk@conference.freeswitch.org:8080/RPC2'; my $dialout = 'sofia/conference.freeswitch.org/#@switch.asterlink.com'; my $dft_name = "FreeSWITCH"; my $dft_num = "2137991400"; ############################################################################################### sub lookup_num($) { my $num = shift; my ($npa,$nxx,$station) = $num =~ /^(\d{3})(\d{3})(\d{4})$/; my $ua = LWP::UserAgent->new( timeout => 20); my $URL = 'http://www.anywho.com/qry/wp_rl'; $URL .= '?npa=' . $npa . '&telephone=' . $nxx . $station; my $req = new HTTP::Request GET => $URL; my $res = $ua->request($req); if ($res->is_success()) { $txt = $res->content; } if ($txt) { my ($info) = $txt =~ /\<\!\-\- listing \-\-\>(.*?)\<\!\-\- \/listing \-\-\>/smi; my ($name) = $info =~ /(.*?)<\/b>/i; my ($addr) = $info =~ /\
(.*?)\<\/DIV\>/si; $addr =~ s/<[^>]+>|^\s*|\s*$//msg; ($name,$addr); } } my ($cmd, $arg) = @ARGV; my $admin = 0; my $now = time; my $cgi = new CGI; if ($ENV{SCRIPT_NAME} =~ /admin/ && $ENV{REMOTE_USER}) { foreach ($cgi->param) { $F{$_} = $cgi->param($_); } $admin++; } my $server = Frontier::Client->new(url => $server_url); print "Content-Type: text/html\n\n"; print "FreeSWITCH Conference Manager"; print ""; print "
FreeSWITCH Conference Manager
"; print "
"; print "
[Refresh | "; if ($admin) { print "Luser"; } else { print "Admin"; } print "]
"; print "
"; my $sleep = 30; if ($admin) { my @args; my $o; if ($F{tick}) { @tick = $cgi->param("tick"); } if ($F{act} =~ /dial/i) { @args = split(" ", $F{file}); my $name = $dft_name; my $num = $dft_num; $str = shift @args; if ($str !~ /\//) { my $num = $dialout; $num =~ s/\#/$str/g; $str = $num; } if ($args[0]) { $num = $args[0]; } if ($args[1]) { $name = $args[1]; } $o = $server->call('freeswitch.api', "conference", "$F{conf} dial $str none $name $num"); } elsif ($F{act} =~ /play/i) { if ($F{tick}) { foreach (@tick) { $o .= $server->call('freeswitch.api', "conference", "$F{conf} play /usr/local/freeswitch/sounds/$F{file} $_") . "
\n"; } } else { $o = $server->call('freeswitch.api', "conference", "$F{conf} play /usr/local/freeswitch/sounds/$F{file}"); } } elsif ($F{act} =~ /speak/i) { if ($F{tick}) { foreach (@tick) { $o .= $server->call('freeswitch.api', "conference", "$F{conf} saymember $_ $F{file}") . "
\n"; } } else { $o = $server->call('freeswitch.api', "conference", "$F{conf} say $F{file}"); } } if (!$o && $F{tick}) { my $do; if (exists $F{file}) { if ($F{act} =~ /transfer/i) { $o .= $server->call('freeswitch.api', "conference", "$F{conf} transfer $F{file} " . join(" ", @tick)) . "
\n"; } elsif ($F{act} =~ /vol|gain/i) { if ($F{act} =~ /vol/i) { $do = "volume_out"; } elsif ($F{act} =~ /gain/i) { $do = "volume_in"; } foreach (@tick) { $o .= $server->call('freeswitch.api', "conference", "$F{conf} $do $_ $F{file}") . "
\n"; } } } if (!$o) { if ($F{act} =~ /kick/i) { $do = "kick"; } elsif ($F{act} =~ /unmute/i) { $do = "unmute"; } elsif ($F{act} =~ /mute/i) { $do = "mute"; } foreach (@tick) { $o .= $server->call('freeswitch.api', "conference", "$F{conf} $do $_") . "
\n"; } } } if ($o) { $sleep = 1; print "Last Command Output:
$o" . "
"; } } print qq##; my $list = $server->call('freeswitch.api', "conference", "list"); my @conf_list; my $ref; foreach my $l (split("\n", $list)) { if ($l =~ /^Conference\s*(\S+)\s*(.*)/) { $ref = {conf => $1, data => $2, fields => []}; push @conf_list, $ref; next; } my @a = split(";",$l); #"$a[0] $a[3] $a[4] ($a[5]) [$a[1]]\n"; push @{$ref->{fields}}, \@a; } sub bynum { $a->[0] <=> $b->[0] } foreach my $conf (@conf_list) { my $rc = 0; if ($admin) { print qq#
\n#; } my $REGFILE = "/usr/local/freeswitch/confbot/$conf->{conf}.dump"; open I,"$REGFILE"; $/ = undef; my $REGISTRY = eval ; close I; $/ = "\n"; print "Conference $conf->{conf} $conf->{data}
"; print "\n"; print ""; if ($admin) { print ""; } #print "\n"; print "\n"; foreach (sort bynum @{$conf->{fields}}) { my $ec; #my ($ec, $number) = lookup_num($_->[4]); if ($REGISTRY->{nickmap}->{$_->[4]}) { $ec = $REGISTRY->{nickmap}->{$_->[4]}; } my $bgc = $rc++ % 2 == 0 ? "ccccff" : "ddddff"; my $title = " Number: $_->[4] \n Name: $_->[3] ($ec)\n Channel: $_->[1]"; $title =~ s/ /\ \;/g; print ""; if ($admin && $_->[0]) { print "\n"; } $_->[3] =~ s/\@.*//g; $_->[4] =~ s/\@.*//g; $_->[5] =~ s/hear/E/; $_->[5] =~ s/speak/M/; my $id = sprintf "%0.7d", $_->[0]; print ""; print ""; print ""; print ""; print ""; print "\n"; } print "
 IDNameNumberFlagsVolumeChannel
IDNumberNameFlagsVolume
[0]>$id$_->[4]$_->[3] "; if ($ec) { print "($ec)"; } print "$_->[5]$_->[6]/$_->[7]/$_->[8]
\n"; print "
"; if ($admin) { my $s = qq#style="font-family:verdana;font-size:9px;border-width:1px;border-style:outset;width:55px"#; print qq#\n#; print qq#

\n#; print qq# #; print qq# #; print qq# #; print qq# #; print qq# #; print qq# #; print qq# #; print qq# #; print qq##; print qq##; print qq#
\n#; } } if (!@conf_list) { print "

No Active Conferences


"; } print "
"; print "
" x 2; print "
";