3 # Convert a WAV file to rmd format
5 require './vgetty-lib.pl';
7 &error_setup($text{'upload_err'});
8 $in{'wav'} || &error($text{'upload_emessage'});
10 $temp1 = &transname();
11 open(TEMP, ">$temp1");
12 print TEMP $in{'wav'};
14 if (&rmd_file_info($temp1)) {
15 # Already in RMD format .. just use
19 # Convert to PVF format
20 $temp2 = &transname();
21 $out = &backquote_logged("wavtopvf $temp1 $temp2 2>&1");
26 &error(&text('upload_ewav', "<pre>$out</pre>"));
29 # Convert to RMD format
30 @formats = &list_rmd_formats();
31 $format = $formats[$in{'format'}];
32 $rmdfile = &transname();
33 $out = &backquote_logged("pvftormd $format->{'code'} $format->{'bits'} $temp2 $rmdfile 2>&1");
38 &error(&text('upload_epvf', "<pre>$out</pre>"));
43 @conf = &get_config();
44 $dir = &messages_dir(\@conf);
45 $in{'wav_filename'} =~ s/^.*[\/\\]//;
46 $in{'wav_filename'} =~ s/\.wav$//i;
47 if (-r "$dir/$in{'wav_filename'}.rmd") {
48 &error(&text('upload_esame', "$in{'wav_filename'}.rmd"));
50 $index = &messages_index(\@conf);
52 @index = map { chomp; $_ } <INDEX>;
55 $bak = &find_value("backup_message", \@conf);
56 push(@index, $bak) if (-r "$dir/$bak");
58 push(@index, "$in{'wav_filename'}.rmd");
59 system("mv $rmdfile $dir/$in{'wav_filename'}.rmd");
60 &open_lock_tempfile(INDEX, ">$index");
61 &print_tempfile(INDEX, map { "$_\n" } @index);
62 &close_tempfile(INDEX);
63 &webmin_log("upload", undef, undef,
64 { 'file' => "$in{'wav_filename'}.rmd" });
66 # Save the format type
67 $config{'format'} = $in{'format'};
68 &write_file("$module_config_directory/config", \%config);
69 &redirect("list_messages.cgi");