This file contains the two cgi files needed to run Octave cgi. File goOctave.cgi ================= #!/usr/bin/perl # # Octave-cgi main file... written by mai@ms.uky.edu. # The code is under GPL 2.0 copyright. # For security reason, Octave's file/directory commands are disabled. my($temp); $temp = "/mnt/disknt1/statguest/statweb/public_html/tmp"; $allowedhost = '\.edu'; #use strict; use CGI; my($results, $in); my($q)= new CGI; # Reconstruct any inputs #if ($results=$q->param('CALLER')) { # $results=''; # } #@input = $q->param('INPUT'); $in=join("\n",$q->param('INPUT')); # Print input form print $q->header, ' Octave-cgi

Octave-cgi

Release 1

Program Input

'.$results.'
'; # Basic security checks if (($q->referer()) && ($q->referer() !~ /$allowedhost\//)) { print 'Sorry, the website which sent you here is not allowed to run scripts here. Email the author of the previous page and ask them to look into it.'; exit; } if ($in) { # Give our input (if any) to a file , filter out some commands. chdir($temp); open(R, ">$temp/octave2.in"); print R "gset term gif\n"; print R "gset output \"foo.gif\"\n"; $in =~ s/\r//g; $in =~ s/(dir|shell|system|rmdir|ls|mkdir|rename|unlink)[^\n]*//g; $in =~ s/(umask|mkfifo|readdir|popen|fork|cd|chdir|getpw)[^\n]*//g; # I think they're the only really nasty things to trap... print R $in."\n"; # End it politely (not an EOF at the end of a command) print R "quit\n"; close R; my $x = system(`octave --traditional -x -H -f <$temp/octave2.in >$temp/octave2.out`); my $x = system(`chmod 644 foo.gif`); # Read the output open(IN, "$temp/octave2.out"); # Tidy it up for HTML $results = join(" ",); $results =~ s/&/&/g; $results =~ s//>/g; close(IN); # Print it out print '
Program Output
*** Octave-cgi reference '.$$.':'
.`date +%Y%m%d%H%M%S`."\n".$results
.'

Graphical Output (if any) :
If the graph showing is an older plot, click the refresh button on your browser. We only provide one page gif graphics over web.'; # Have we got a call-back name? # if ($in=$q->param('CALLER')) { # print '
Return to '.$in.''; # } } print '
'; File gomatlab.cgi ================= #!/usr/bin/perl # # Octave-cgi main file... written by mai@ms.uky.edu. # The code is under GPL 2.0 copyright. # For security reason, Octave's file/directory commands are disabled. my($temp); $temp = "/mnt/disknt1/statguest/statweb/public_html/tmp"; $allowedhost = '\.edu'; #use strict; use CGI; my($results, $in); my($q)= new CGI; # Reconstruct any inputs #if ($results=$q->param('CALLER')) { # $results=''; # } #@input = $q->param('INPUT'); $in=join("\n",$q->param('INPUT')); # Print input form print $q->header, ' Octave-cgi

Octave-cgi

Release 1

Program Input

'.$results.'
'; # Basic security checks if (($q->referer()) && ($q->referer() !~ /$allowedhost\//)) { print 'Sorry, the website which sent you here is not allowed to run scripts here. Email the author of the previous page and ask them to look into it.'; exit; } if ($in) { # Give our input (if any) to a file , filter out some commands. chdir($temp); open(R, ">$temp/octave.in"); $in =~ s/\r//g; $in =~ s/(dir|shell|system|rmdir|ls|mkdir|rename|unlink)[^\n]*//g; $in =~ s/(umask|mkfifo|readdir|popen|fork|cd|chdir|getpw)[^\n]*//g; # I think they're the only really nasty things to trap... print R $in."\n"; # End it politely (not an EOF at the end of a command) print R "quit\n"; close R; my $x = system(`octave --traditional -x -H -f <$temp/octave.in >$temp/octave.out`); # Read the output open(IN, "$temp/octave.out"); # Tidy it up for HTML $results = join(" ",); $results =~ s/&/&/g; $results =~ s//>/g; close(IN); # Print it out print '
Program Output
*** Octave-cgi reference '.$$.':'
.`date +%Y%m%d%H%M%S`."\n".$results
.'
'; # Have we got a call-back name? # if ($in=$q->param('CALLER')) { # print '
Return to '.$in.''; # } } print '
';