#!/usr/bin/perl

# ###############################################################
# configuration zone
#

# where is the perl I should use?
$perl="/usr/bin/perl";

# where is your standard-coverpage?
$scoverpage="/coverpage";

# where is your faxspool-directory?
$faxspool="/usr/local/bin/faxspool";

# what should be the default-from-name?
$fromname = "Default - From - Name";

# what should be the default-from-name?
$toname = "Default - To - Name";

# where is your date-command?
$time="/bin/date";

# incoming-directory for your faxes
$incoming="/usr/spool/fax/incoming/";

# choose your extension to tell your webclient that this is a g3-fax
$contenttype = "application\/g3fax";

# whereis g3topbm?
$g3="/usr/bin/g3topbm";

# whereis ppmtogif?
$togif="/usr/local/bin/ppmtogif";

#where is your webfax located from the system-root?
$tmppath="/home/www/teddy/mgetty+sendfax/webviewer/";

#where is your webfax located from the server-root?
$webpath="/mgetty+sendfax/webviewer/";

#how  is your tmp-directory for www called??
$tmpdir="tmp/";

# where is ppmquant? We'll need it, because pbmscale sometimes produces
# too many colors - the number is the number of used colors - I'm not
# happy with the result but 256 colors is much more ugly.
$quant="/usr/local/bin/ppmquant 6";

# where is pbmscale?
$scale="/usr/local/bin/pnmscale";

# to scale: how much? 1=100% 0.5=50% (x and y seperately, in case someone
# preferes different scalings
$x="0.25";
$y="0.25";

# how many pictures do you want in worst case on one html-page?
$pgcounter = 3;

# where is your shortfax.pl located?
$shortfax = "../shortfax.pl";


#
# end of configuration zone
# #######################################################################

# prolog
system ("/bin/mkdir webviewer");
system ("/bin/mkdir webviewer/tmp");
system ("/bin/chmod 755 webviewer");
system ("/bin/chmod 777 webviewer/tmp");

# starting to create Files
#

open (OUT, ">shortfax.pl");
print OUT <<EOF;
#\!$perl

\$scoverpage="$scoverpage";
\$faxspool="$faxspool";
\$fromname="$fromname";
\$toname="$toname";
\$time=`$time`;
EOF

open (IN, "shortfax.in");
while (<IN>)
{
print OUT $_;
}

close (IN);
close (OUT);



open (OUT, ">webviewer/givg3.pl");
print OUT <<EOF;
#\!$perl


\$incoming="$incoming";
\$contenttype="$contenttype";
\$incoming="$incoming";
\$g3="$g3";
\$togif="$togif";
\$tmppath="$tmppath";
\$webpath="$webpath";
\$tmpdir="$tmpdir";
EOF

open (IN, "givg3.in");
while (<IN>)
{
print OUT $_;
}
close (IN);
close (OUT);



open (OUT, ">webviewer/givsmallgif.pl");
print OUT <<EOF;
#\!$perl

\$incoming="$incoming";
\$g3="$g3";
\$togif="$togif";
\$quant="$quant";
\$scale="$scale";
\$x="$x";
\$y="$y";
\$tmppath="$tmppath";
\$webpath="$webpath";
\$tmpdir="$tmpdir";
EOF

open (IN, "givsmallgif.in");
while (<IN>)
{
print OUT $_;
}
close (IN);
close (OUT);

open (OUT, ">webviewer/givgif.pl");
print OUT <<EOF;
#\!$perl

\$incoming="$incoming";
\$g3="$g3";
\$togif="$togif";
\$tmppath="$tmppath";
\$webpath="$webpath";
\$tmpdir="$tmpdir";
EOF

open (IN, "givgif.in");
while (<IN>)
{
print OUT $_;
}
close (IN);
close (OUT);



open (OUT, ">webviewer/index.pl");
print OUT <<EOF;
#\!$perl

\$incoming="$incoming";
EOF

open (IN, "index.in");
while (<IN>)
{
print OUT $_;
}
close (IN);
close (OUT);


open (OUT, ">webviewer/showas.pl");
print OUT <<EOF;
#\!$perl

\$incoming="$incoming";
\$g3="$g3";
\$togif="$togif";
\$tmppath="$tmppath";
\$tmpdir="$tmpdir";
\$pgcounter="$pgcounter";
\$shortfax="$shortfax";
EOF

open (IN, "showas.in");
while (<IN>)
{
print OUT $_;
}
close (IN);
close (OUT);

#epilog
system ("/bin/chmod 755 webviewer/*.pl");
system ("/bin/chmod 755 *.pl");
system ("/bin/rm *.in");

exit 0
