#!/usr/bin/suidperl -U # # vbox Anrufbeantworter Abfrage # # # # Letzte Modifikation: 29.03.2002, lf # # --- used modules use Time::localtime; use File::Copy; # --- global constants $vbox_path = '/var/spool/vbox'; $vbox_user = 'leo'; # --- security $ENV{'PATH'} = ""; my %data; $data = read_form (); # --- todo == "Abfragen" -> play message if ($data{'todo'} eq "Abfragen") { $data{'message'} =~ s/[^0-9-]//g; print "Content-type: audio/x-wav\n\n"; $filename_src = $vbox_path . "/" . $vbox_user . "/incoming/" . $data{'message'}; $filename_dst = "/tmp/" . $data{'message'}; copy ($filename_src, $filename_dst); # .AU-File erzeugen $command = "/usr/bin/vboxtoau < $filename_dst"; open (PIPE, "$command |"); open (AUSND, ">$filename_dst.au"); print AUSND ; close (AUSND); close (PIPE); # .AU mittels sox in .WAV umwandeln $command = "/usr/bin/sox $filename_dst.au $filename_dst.wav"; open (PIPE, "$command |"); close (PIPE); # .WAV an Browser schicken open (WAVSND, "<$filename_dst.wav"); print ; close (WAVSND); # Temporaere Dateien loeschen unlink ("$filename_dst"); unlink ("$filename_dst.wav"); unlink ("$filename_dst.au"); } # --- print summary form else { print "Content-type: text/html\n\n"; print < vbox

Anrufbeantworter-Abfrage

Eingegangene Anrufe


EOM if ($data{'todo'} eq "Info") { print "Informationen zum Anruf\n"; $command = "/usr/bin/vboxmode $vbox_path/$vbox_user/incoming/" . $data{'message'}; open (PIPE, "$command |"); print "
\n";
     print ;
     print "
\n"; close (PIPE); } print < EOM } # --- sub ListCalls () - list vbox calls from $user sub ListCalls { $user_path = join ("","/var/spool/vbox/" . $vbox_user . "/incoming"); @directory = split (/\n/, `/bin/ls -1t $user_path`); foreach $file (@directory) { my $call_time = $file; $call_time =~ s/-.*//g; $call_time =~ s/^[0]*//g; my $tm = localtime ($call_time); my $call_time = sprintf ("%02d.%02d.%04d - %02d:%02d", $tm->mday, $tm->mon + 1, $tm->year + 1900, $tm->hour, $tm->min, $tm->sec); print "\n"; } } sub read_form { my ($buffer, $pair, $name, $value); my @pairs; if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } @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; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if (defined $data{$name}) { $data{$name} = $data{$name}.",".$value; } else { $data{$name} = $value; } } }