Perl CGI Math Generator script not working

apps

#1

Here’s the script.

#!/usr/bin/perl -w

math.cgi

Generate math problems

Dave Regan

regan@peak.org

19 November 1997

1865 NW Locust

Corvallis OR 97330 USA

Public domain, no copyright claimed.

Future directions

-----------------

Format divide for long division.

Configuration

use strict;
use vars qw($ApplRoot $Font $PerLine $TotalProblems %Types %Vars $Version);
use vars qw(Êllable ÊllFuncs $DoUnderscore $InCGI $NoLocalcode %Symbols);

This is where the template pages are.

($ApplRoot = $ENV{‘SCRIPT_FILENAME’} || “WHERE_ARE_WE”) =~ s#/[^/]+$##;

This is the font size for the problems

$Font = “4”;

This is the number of puzzles to a column

$PerLine = 5;

Version ID

$Version = “v0.09”;

Main program

Start Webc

$InCGI = 1; # Put webc into CGI mode
$NoLocalcode = 1; # Don’t allow webc to process #localcode
$DoUnderscore = 1; # Require underscores in symbols
Webc(); # Start webc
$CallFuncs{‘GenAnswers’} = 1;
$CallFuncs{‘GenProblems’} = 1;
$CallFuncs{‘PrintSymbols’} = 1;
$Symbols{‘VERSION_MATH’} = $Version;

print “Content-type: text/html\n\n”;

PrintHash(“Environment”, %ENV);

if (defined($ENV{‘REQUEST_METHOD’}) && $ENV{‘REQUEST_METHOD’} eq “POST”)
{
ParseFormVariables();
$Font = $Vars{‘font’}
if (defined($Vars{‘font’}) && $Vars{‘font’} > 1 &&
$Vars{‘font’} < 10);
$PerLine = $Vars{‘perline’}
if (defined($Vars{‘perline’}) && $Vars{‘perline’} > 1 &&
$Vars{‘perline’} < 30);
$Symbols{‘font’} = $Font;
$Symbols{‘perline’} = $PerLine;
if (defined($Vars{‘prob0’}))
{

Answering the questions

ScoreTest();
Compile("$ApplRoot/answered.wc");
}
else
{

Initial start.

PrintHash(“Vars”, %Vars);

CheckCounts();
Compile("$ApplRoot/math.wc");
}
}

CheckCounts

Set the counts of all of the types of puzzles.

sub CheckCounts
{
my($base, $name);

srand(time() ^ ($$ + ($$ << 15)));
$TotalProblems = 0;
for $name (keys %Vars)
{
next unless ($name =~ /(.*)count$/);
$base = $1;
$Vars{$name} =~ s/\D//g;
$Vars{$name} = 10 if ($Vars{$name} eq “”);
$Vars{$name} = 0 if (!defined($Vars{$base}));
if ($Vars{$name} != 0)
{
$Types{$base} = $Vars{$name};
$TotalProblems += $Types{$base};
}
}
}

DoAdd

Generate an addition problem.

sub DoAdd
{
my($prob) = @_;
my($min, $max, $op1, $op2, $str, $width, $width2);

$min = 0;
$max = $Vars{‘addmax’};
$max = 100 if (!defined($max) || $max !~ /^\d+$/);
$min = -$max if (defined($Vars{‘addnegop’}));

while (1)
{
$op1 = int(rand(-$min + $max + 1) + $min);
$op2 = int(rand(-$min + $max + 1) + $min);
next if ($op1 + $op2 < 0 && !defined($Vars{‘addnegres’}));
last;
}

PrintProb($prob, “+”, $op1, $op2);
return "$op1 + $op2 = " . ($op1 + $op2);
}

DoDivi

Generate a division problem w/o remainders

sub DoDivi
{
my($prob) = @_;
my($min, $max, $op1, $op2, $str, $width, $width2);

$min = 0;
$max = $Vars{‘divimax’};
$min = -$max if (defined($Vars{‘divinegop’}));

while (1)
{
$op1 = int(rand(-$min + $max + 1) + $min);
$op2 = int(rand(-$min + $max + 1) + $min);
next if ($op2 == 0);
next if ($op1 / $op2 < 0 && !defined($Vars{‘divinegres’}));
next if (int($op1 / $op2) != ($op1 / $op2));
last;
}

PrintProb($prob, “÷”, $op1, $op2);
return "$op1 / $op2 = " . ($op1 / $op2);
}

DoDivr

Generate a division problem with remainders

sub DoDivr
{
my($prob) = @_;
my($min, $max, $op1, $op2, $str, $width, $width2);

$min = 0;
$max = $Vars{‘divrmax’};
$min = -$max if (defined($Vars{‘divrnegop’}));

while (1)
{
$op1 = int(rand(-$min + $max + 1) + $min);
$op2 = int(rand(-$min + $max + 1) + $min);
next if ($op2 == 0);
next if ($op1 / $op2 < 0 && !defined($Vars{‘divrnegres’}));
last;
}

PrintProb($prob, “÷”, $op1, $op2);
return "$op1 / $op2 = " . int($op1 / $op2) . " r " . ($op1 % $op2);
}

DoMul

Generate a multiplication problem

sub DoMul
{
my($prob) = @_;
my($min, $max, $op1, $op2, $str, $width, $width2);

$min = 0;
$max = $Vars{‘mulmax’};
$min = -$max if (defined($Vars{‘mulnegop’}));

while (1)
{
$op1 = int(rand(-$min + $max + 1) + $min);
$op2 = int(rand(-$min + $max + 1) + $min);
next if ($op1 * $op2 < 0 && !defined($Vars{‘mulnegres’}));
last;
}

PrintProb($prob, “×”, $op1, $op2);
return "$op1 * $op2 = " . ($op1 * $op2);
}

DoSub

Generate a subtraction problem

sub DoSub
{
my($prob) = @_;
my($min, $max, $op1, $op2, $str, $width, $width2);

$min = 0;
$max = $Vars{‘submax’};
$min = -$max if (defined($Vars{‘subnegop’}));

while (1)
{
$op1 = int(rand(-$min + $max + 1) + $min);
$op2 = int(rand(-$min + $max + 1) + $min);
next if ($op1 - $op2 < 0 && !defined($Vars{‘subnegres’}));
last;
}

PrintProb($prob, “-”, $op1, $op2);
return "$op1 - $op2 = " . ($op1 - $op2);
}

EnrollSymbols

Put all of the variables from the hash into the symbol table.

This might be a good routine to put into Webc.

#sub EnrollSymbols

{

my($hash) = @_;

my($key);

for $key (keys(%$hash))

{

$Symbols{"${key}"} = $$hash{$key};

}

}

GenAnswers

Generate answers for each of the problems.

Incorrect problems are marked in red, with the

correct answer listed as well as the user’s answer.

sub GenAnswers
{
my($column, $correct, $op1, $op2, $operator, $prob);
my($problem, $result, $user, $width);

$width = 100 / $PerLine;
print “<table width=“100%”>\n”;
for ($problem = 0, $column = 0; defined($Vars{“prob$problem”});
$column++, $problem++)
{

Make the table item

print “

” if ($column == $PerLine);
$column = 0 if ($column == $PerLine);
print “” if ($column == 0);

print “<td width=”$width%" align=right>";
$correct = IsCorrect($problem);
$user = $Vars{“res$problem”};
($prob = $Vars{“prob$problem”}) =~ s/\s//g;
if ($prob =~ m/(-?.?)([-+*/])(.)=(.)/)
{
($op1, $operator, $op2, $result) = ($1, $2, $3, $4);
$operator = “×” if ($operator eq "
");
$operator = “÷” if ($operator eq “/”);
PrintProb($problem, $operator, $op1, $op2,
$correct, $user, $result);
}
print “”;
}

print “

\n”;
}

GenProblems

Generate a set of problems.

Randomaly generate problems from the set that are allowed

until all problems have been generated.

sub GenProblems
{
my($column, $lasttype, $prob, $problem, $rnd, $type, $width);

$width = 100 / $PerLine;
print “<table width=“100%”>\n”;

print “<font size=$Font face=“fixed”>”;

for ($problem = 0, $column = 0; $problem < $TotalProblems;
$column++, $problem++)
{

Make the table item

print “” if ($column == $PerLine);
$column = 0 if ($column == $PerLine);
print "

" if ($column == 0);

Find the type of problem to generate

$rnd = int(rand($TotalProblems));
$lasttype = undef;
for $type (keys %Types)
{
$lasttype = $type;
last if ($rnd < $Types{$type});
$rnd -= $Types{$type};
}
$type = $lasttype;
last if (!defined($type));
delete $Types{$type} if (–$Types{$type} <= 0);

print “<td width=”$width%" align=right>";
if ($type eq “add”) { $prob = DoAdd($problem); }
elsif ($type eq “sub”) { $prob = DoSub($problem); }
elsif ($type eq “mul”) { $prob = DoMul($problem); }
elsif ($type eq “divi”) { $prob = DoDivi($problem); }
elsif ($type eq “divr”) { $prob = DoDivr($problem); }
print “<input type=“hidden” name=“prob$problem” value=”$prob">\n";

print “$type problem”;

print “”;
}

print “

\n”;
}

IsCorrect

See if the given problem is correct.

sub IsCorrect
{
my($prob) = @_;
my($ans, $user);

return 0 if (!defined($Vars{“res$prob”}));
return 0 if ($Vars{“res$prob”} =~ /^$/);
($ans = $Vars{“prob$prob”}) =~ s/.=\s//;
$ans =~ s/\s//g;
$ans =~ s/^([-+])0/$1/;
($user = lc($Vars{“res$prob”})) =~ s/\s//g;
$user =~ s/^([-+])0/$1/;
return ($user eq $ans);
}

ParseFormVariables

The variables from a CGI FORM come in on standard input.

Read this string, and break it up into the Vars associative

array.

sub ParseFormVariables
{
my($data, $item, $name, @tbl, $val);

$data = ;

print STDERR "The raw data is $data

\n";

$data =~ s/query…=//g;

$Symbols{‘ORIGDATA’} = $data;
$data =~ s/&\s$//;
@tbl = split(/&/, $data); # Vars separated by &
for $item (@tbl)
{

Process the variables. Be careful to avoid removing needed characters.

chomp($item = unquote($item));
($name, $val) = split(/=/, $item, 2);
$Vars{$name} = $val;
}
}

ParseQueryString

Break apart a query string.

This probably will need to be smarter.

It should unescape values.

#sub ParseQueryString

{

my($field, @fields, $name, $value);

return if (!defined($ENV{‘QUERY_STRING’}) || $ENV{‘QUERY_STRING’} eq “”);

$Symbols{‘ORIGDATA’} = $ENV{‘QUERY_STRING’};

@fields = split(/&/, $ENV{‘QUERY_STRING’});

for $field (@fields)

{

($name, $value) = split(/=/, $field, 2);

$Vars{$name} = unquote($value) if (defined($value));

}

}

PrintHash

Print the contents of a hash.

sub PrintHash
{
my($name, $hash) = @_;
my($key);

print “$name:
\n”;
for $key (sort(keys(%$hash)))
{
print "$key = ", UnEntity($$hash{$key}), “
\n”;
}
}

PrintProb

Print a problem.

I’d like to use to put in an underscore, but netscape

doesn’t print underlines.

sub PrintProb
{
my($prob, $operator, $op1, $op2, $correct, $user, $result) = @_;
my($color, $str, $w2, $width, $width2);

$color = “”;
if (defined($correct))
{
$color = “color=black”;
$color = “color=red” if (!$correct);
}
print “<font size=$Font face=“fixed” $color>”;
$width = length(sprintf("%d", $op1));
$width2 = length(sprintf("%d", $op2));
$width = $width2 if ($width2 > $width);
if ($color ne “”)
{
$width2 = length($user);
$width = $width2 if ($width2 > $width);
$width2 = length($result);
$width = $width2 if ($width2 > $width);
}
$str = sprintf " %${width}d
", $op1;

$str .= sprintf "$operator %${width}d

", $op2;
$str .= sprintf “$operator %${width}d
”, $op2;

$str .= “_” x ($width + 2);

$str .= "

";
$str =~ s/ /\ /g;
print “$str
”;
if ($color eq “”)
{
$w2 = $width + 1;
print “”;
}
else
{
$width += 2;
if ($user ne “”)
{
$str = sprintf “%${width}.${width}s
”, $user;
$str =~ s/ /\ /g;
print $str;
}
if (!$correct)
{
print “<font size=$Font face=“fixed” color=black>”;
$str = sprintf “%${width}.${width}s
”, $result;
$str =~ s/ /\ /g;
print $str;
}
}
print “\n”;
}

PrintSymbols

Print the symbol table.

This is useful for application *.wc files to call to see

what their environment is.

sub PrintSymbols
{
PrintHash(“Symbol table”, %Symbols);
}

ScoreTest

Score the test. Set up appropriate variables.

sub ScoreTest
{
my($count, $right);

PrintHash(“Vars”, %Vars);

$right = 0;
for ($count = 0; defined($Vars{“prob$count”}); $count++)
{
$right++ if (IsCorrect($count));
}
$Symbols{‘TOTAL’} = $count;
$Symbols{‘RIGHT’} = $right;
$Symbols{‘PERCENT’} = 0;
$Symbols{‘PERCENT’} = int(($right / $count) * 100) if ($count > 0);
}

UnEntity

Massage a string so that it will print.

sub UnEntity
{
my($text) = @_;

$text =~ s/&/&/g;
$text =~ s/</</g;
$text =~ s/>/>/g;
return $text;
}

unquote

Unescape a CGI form variable.

sub unquote
{
my($raw) = @_;
my($code, @pieces, $piece);

$raw =~ s/+/ /mg;
@pieces = split(/%/, $raw);
for ($piece = 1; $piece <= $#pieces; $piece++)
{
$pieces[$piece] =~ s/^%//;
$code = substr($pieces[$piece], 0, 2);
$code = hex($code);
$pieces[$piece] = sprintf("%c%s", $code, substr($pieces[$piece], 2));
}
return join("", @pieces);
}

The following section is the webc compiler.
This section is free, and instructions on its
use are located at http://www.ao.com/~regan/Webc.
This has been hacked a fair amount. It is reasonable to
get a new copy to incorporate.

#!/usr/bin/perl -w

webc

A web “compiler”.

This is a simple translator which converts a source file

into a *.html file suitable for being served by the web

server.

This is a mix of perl, html, and C. It is also an ad’hoc

system.

Dave Regan

regan@ao.com

http://www.ao.com/~regan/Webc

31 January 1997

This program and the associated documentation are in the

public domain.

Configuration

#use strict ‘vars’;
use strict ‘refs’;
use strict ‘subs’;
#use diagnostics;

use vars qw(@AllSymbols $DoExpand @MonName);

Main program

sub Webc
{
my($file, $host);

$Symbols{‘VERSION’} = “v0.26”; # Current version ID

@MonName = ( ‘Jan’, ‘Feb’, ‘Mar’, ‘Apr’, ‘May’, ‘Jun’,
‘Jul’, ‘Aug’, ‘Sep’, ‘Oct’, ‘Nov’, ‘Dec’);

Stash a guess for the site name.

It is reasonable for the user to override this.

$DoExpand = 1;
$DoUnderscore = 0;
$ENV{‘LOGNAME’} = “unknown” if (!defined($ENV{‘LOGNAME’}));
$host = hostname;
chomp($host);
$Symbols{‘SITE’} = (gethostbyname($host))[0];
$Symbols{‘USER’} = $ENV{‘LOGNAME’};
$Symbols{‘EMAIL’} = “$Symbols{‘USER’}@$Symbols{‘SITE’}”;
$Symbols{‘HR’} = “


”; # Can be overridden
$CallFuncs{‘DumpVars’} = 1;
@AllSymbols = ();

if (!$InCGI)
{
for $file (@ARGV)
{
if ($file =~ /.html$/)
{
print “Not processing $file. It already is an HTML file.\n”;
next;
}
Compile($file);
}
exit 0;
}

return 1;
}

Compilation routines
Template files exist which describe the work to be done.
Each of these gets turned into an html file with appropriate
substitutions made.
Substitutions include the following macros:
DATE The current date
TIME The current time
MODIFIED The last modified date
SITE The web site name
FILE The current filename
HTMLFILE The current output filename
USER The current username
EMAIL The email of the current user
VERSION The current webc version ID
HR The html code to put out for a
in addition to any the user defines. Some of the standard
definitions are “guesses”, and the user is free to override
any of these.
Preprocessor directives understood:
#include fname A filename to include
Include files nest, but don’t put it into a loop
#call fn Call a specific function
#localcode fname Read a file into the compiler itself.
#define X val Define a value
#pragma name A Webc hack
#if val string Print a string if the val is not 0
#callable fn Indicates that the named function
can be called anyplace it sees “fn()”.

CanonFname

Remove redundancies from a filename.

sub CanonFname
{
my($fname) = @_;

$fname =~ s#/+#/#g;
$fname =~ s#/./#/#g while ($fname =~ m#/./#);
$fname =~ s#^./##g;
$fname =~ s#[^/]+/../## while ($fname =~ m#/../#);
return $fname;
}

Compile

Compile a single file.

sub Compile
{
my($fname) = @_;
my(@tm);

print “Compiling $fname\n”;

Open the file for reading, and also a file for writing.

The output filename is *.html.

$fname = CanonFname($fname);
($Symbols{‘HTMLFILE’} = $fname) =~ s/.[a-zA-Z]*$/.html/;

Define appropriate symbols

$Symbols{‘FILE’} = $fname;
@tm = localtime();
$Symbols{‘DATE’} =
sprintf “%d %s %d”, $tm[3], $MonName[$tm[4]], $tm[5] + 1900;
$Symbols{‘TIME’} = sprintf “d:d:d”, $tm[2], $tm[1], $tm[0];
@tm = localtime((stat($fname))[9]);
$Symbols{‘MODIFIED’} =
sprintf “%d %s %d”, $tm[3], $MonName[$tm[4]], $tm[5] + 1900;

if ($InCGI)
{
$Symbols{‘HTMLFILE’} = “”;
*OUT = *STDOUT;
}
else
{
if (!open(OUT, “>$Symbols{‘HTMLFILE’}”))
{
print “Cannot open html file $Symbols{‘HTMLFILE’}\n”;
return;
}
}

CompileRead(".", $fname);

close OUT if (!$InCGI);
}

CompileRead

Read in a file.

sub CompileRead
{
my($parentdir, $fname) = @_;
local(*IN);
my($dir, $line, $string, $sym, $val);

Make a directory which tracks what is being read.

The directory may have redundant dir/…/ in it, but that’s ok.

$dir = $fname;
$dir = “$parentdir/$fname” if ($fname !~ m#^/#);
$dir =~ s#/[^/]$##;
#print STDERR “Opening $fname, dir is $dir\n”;
$fname =~ s#.
/##;

if (!open(IN, “<$dir/$fname”))
{
print “Cannot open source file $dir/$fname\n”;
return;
}

print “Reading $dir/$fname\n”;

@AllSymbols = ();
while ()
{
#print STDERR “Process $_”;
if (/^\s*#/)
{

print STDERR “Process $_”;

#print STDERR “.”;
chomp;
$line = $_;

See if we should include a file

CompileRead($dir, Expand($1))
if ($line =~ /^\s*#\sinclude ["<]([^">]+).*/);

See if we should source a file

require("$dir/" . Expand($1))
if (!$NoLocalcode &&
$line =~ /^\s*#\slocalcode ["<]([^">]+).*/);

See if there is a procedure to call

if ($line =~ /^\s*#\s*call/)
{
$line = Expand($line);

$Directory = $dir;

If running as the real user, let them call any

function in any way that they want. If it is part

of a CGI program on a restricted machine, then

only call functions which are in the CallFuncs hash.

eval("$1(’$2’)") if ($line =~ /^\s*#\scall\s+["<]?([^"\s>]+).?\s(.*)/);

if ($line =~ /^\s*#\scall\s+["<]?([^"\s>]+).?\s(.*)/)
{
my($func, $param) = ($1, $2);
if ($NoLocalcode)
{
if ($CallFuncs{$func} eq “”)
{
print OUT “Function $func is not registered in CallFuncs\n”;
}
else
{
eval("$func(’$param’)");
}
}
else
{
eval("$func(’$param’)");
}
}
}

See if this is a variable definition

if ($line =~ /^\s*#\sdefine\s+(\S+)\s+(.)/)
{
$Symbols{$1} = Expand($2);
@AllSymbols = ();
}

See if this is a pragma (hack)

Pragma($1) if ($line =~ /^\s*#\s*pragma\s+(\S+)/);

See if this is a simple #if

if ($line =~ /^\s*#\sif\s+(\S+)\s+(.)/)
{
$val = Expand($1);
$string = Expand($2);
if ($val ne “” && $val ne “0”)
{
print OUT $string;
}
}

See if this defines a callable function

$Callable{$1} = 1 if ($line =~ /^\s*#\scallable\s+(.)/);
}
else
{
$_ = Expand($_);

print OUT “$_”;
}
}
close IN;
}

Expand

Expand the macros in a string.

This can cause loops in a number of ways. We will take

the lazy way out and keep a counter for the number of

expansions and give up after awhile.

The order of expansion is not guarenteed.

This is a pig if there are very many symbols (> 100).

I have made some attempts at speeding up the process,

but it is still slow.

sub Expand
{
my($var) = @_;
my($arg, $back, $count1, $count2, $fn, $front, $repl, $sym);

$_ = $var;
return $_ if (!$DoExpand);

@AllSymbols = keys %Symbols if (scalar(@AllSymbols) == 0);

@AllSymbols = keys %Symbols; # People change the $Symbols too much.
for ($count1 = 0; $count1 < 100; $count1++)
{

Call any functions found

$count2 = 0;
for $fn (keys Êllable)
{
next if ($fn eq “”);
while (/(.)$fn\s((.?))(.)/)
{
$count2++;
($front, $arg, $back) = ($1, $2, $3);
$arg =~ s/([’])/\$1/g;
$_ = $front . eval("$fn(’$arg’)") . “$back\n”;
}
}

Expand any macros found

if (!$DoUnderscore || $_ =~ //)
{
for $sym (@AllSymbols)
{
$repl = $Symbols{$sym};
$count2 += s/$sym/$repl/g;
last if ($DoUnderscore && $
!~ //);
}
}
last if ($count2 == 0);
}
return $
;
}

Pragma

A place to collect hacks. The less said about these the better.

sub Pragma
{
my($pragma) = @_;

if ($pragma eq “nodefine”) { $DoExpand = 0; }
elsif ($pragma eq “define”) { $DoExpand = 1; }
elsif ($pragma eq “nounderscore”) { $DoUnderscore = 0; }
elsif ($pragma eq “underscore”) { $DoUnderscore = 1; }
}

RootRelative

We have a filename which is supposed to be relative from

the root of the document tree. However, the filename will

be used relative to the current file being compiled (e.g.

the web browser). So modify the name to be relative to

the current filename.

sub RootRelative
{
my($reference, $fname) = @_;
my($count, $tmp);

return $fname if ($fname =~ m#^/#);

($tmp = CanonFname($reference)) =~ s#[^/]##g;
for ($count = 0; $count < length($tmp); $count++)
{
$fname = “…/$fname”;
}
return $fname;
}

Routines for the user to call.

Test

See if this gets a parameter

sub Test
{
my($param) = @_;

print “Param is “$param”\n”;
}

Modified

Print an appropriate modification notice.

sub Modified
{
print OUT “
Last modified $Symbols{‘MODIFIED’}
\n”;
}

DumpVars

Dump the current symbol table.

sub DumpVars
{
my($key);

print OUT “

\n”;
for $key (sort(keys %Symbols))
{
print OUT “#define $key\t$Symbols{$key}
\n”;
}
}

I get a 500 Internal Server Error.

I CHMODed it correctly, and set the perl shebang to the installation directory usr/bin/perl.


#2

You can check your error log for more information on the error; your logs can be found in the “logs” directory you will find in your main “user” directory.

It looks like, at least, there may be character encoding issues with your script, as around line 27 you will find:

[quote]use vars qw($ApplRoot $Font $PerLine $TotalProblems %Types %Vars $Version);
use vars qw(Êllable ÊllFuncs $DoUnderscore $InCGI $NoLocalcode %Symbols);[/quote]
Note the “special characters” in variables “Êllable” and “ÊllFuncs” .

Is the script down-loadable from somewhere? It might have gotten “munged” with page encoding if it was "cut ‘n’ paste"ed from a web page.

–rlparker


#3

Well, you can download the archive from www.armoredpenguin.com/math/math.tar.gz.

I asked the guy if I could use it, and he said definitely.

However, I copypasta’d the code from Dreamweaver.


#4

Yeah, it lookes like Dreamweaver “borked” the character encoding. I downloaded the script from the author’s website at http://cornvalley.peak.org/math/math.txt, modified the !shebang for Dreamhost, uploaded it in ASCII mode, and it ran without error.

It did not, however generate output to the screen, but I have not even downloaded or looked at the tarball available via the “archive” link at http://cornvalley.peak.org/math/; (I only glanced at the actual code in the script you provided).

I suspect there are installation instructions, or other important stuff in the tarball.

–rlparker


#5

It’s usually not good practice, imho, to paste copies of long listings when a simple link is available.

Unfortunately, I didn’t find a readme or instructions with the tarball, but did get it working. Here’s what I did more or less, starting from my domain directory, /home/user/example.com/:

mkdir mathdir
cd mathdir
wget http://www.armoredpenguin.com/math/math.tar.gz
tar xvzf math.tar.gz
cd …
chmod 755 -R mathdir
cd mathdir/math-0.09
wget http://www.armoredpenguin.com/images/cornvalley.green.jpg

Edit math.cgi with favorite editor; change shebang to

#!/usr/bin/perl -w

Edit index.html; change 2 image sources to local file; differences:

<

[quote]

[/quote]

< PEAK

[quote]PEAK

[/quote]

Now going to www.example.com/mathdir/math-0.09/ works for me.

You are welcome to a refund.-Michael;Comparing ‘DH of today’ with ‘DH of old’ does not serve much purpose.-Dallas


#6

Sorry about the code. I’m usually used to forums run on either phpBB, vBulletin, or IPB :slight_smile:

Thanks. I’ll see if I can fix it.

Also, I created my own PHP home file, so no need to edit that.


#7

It’s still not working.


#8

Hmm… should I turn off FastCGI?

OK. I turned off FastCGI.