Parent Directory
|
Revision Log
initial import
1 #!/usr/bin/perl 2 ############################################################ 3 # File: alias.pl 4 # Copyright: WeBWorK 1997 all rights reserved 5 # Description: This script will read, interpret, and output certain files 6 # not normally accessible by the browser. It can be used 7 # to provide real time creation of .gif files 8 ############################################################ 9 10 11 use lib '/ww/webwork/development/'; # mainWeBWorKDirectory; 12 use strict; 13 14 use CGI qw(:standard); 15 use Global; 16 use Auth; 17 18 # begin Timing code 19 use Benchmark; 20 my $beginTime = new Benchmark; 21 # end Timing code 22 23 24 &CGI::ReadParse; 25 my %inputs = %main::in; 26 27 # get information from CGI inputs (see also below for additional information) 28 my $Course = param('course'); 29 my $User = param('user'); 30 my $Session_key = param('key'); 31 my $psvn = param('probSetKey'); #psvn stands for Problem Set Version Number 32 my $probNum = param('probNum'); 33 my $mode = param('Mode'); 34 my $previousProbNum = $probNum-1 if defined($probNum); 35 my $nextProbNum = $probNum+1 if defined($probNum); 36 37 38 # verify that information has been received 39 unless($Course && $User && $Session_key && $psvn) { 40 &Global::error("Script Error","The script alias.pl did 41 not receive the proper input data.","",""); 42 # die "Content-type: text/html\n\nThe script processProblem.pl did 43 # not receive the proper input data."; 44 } 45 46 # establish environment for this script 47 &Global::getCourseEnvironment($Course); 48 49 my $databaseDirectory = getCourseDatabaseDirectory(); #$Global::databaseDirectory; 50 my $htmlDirectory = getCourseHtmlDirectory(); #$Global::htmlDirectory; 51 my $htmlURL = getCourseHtmlURL(); #$Global::htmlURL; 52 my $scriptDirectory = getWebworkScriptDirectory(); #$Global::scriptDirectory; 53 my $templateDirectory = getCourseTemplateDirectory(); #$Global::templateDirectory; 54 my $courseScriptsDirectory = getCourseScriptsDirectory(); #$Global::courseScriptsDirectory; 55 56 require "${scriptDirectory}$Global::DBglue_pl"; 57 58 59 60 my $permissionsFile = &Global::getCoursePermissionsFile($Course); 61 my $keyFile = &Global::getCourseKeyFile($Course); 62 63 # log access 64 &Global::log_info('', query_string); 65 66 #verify session key 67 &verify_key($User, $Session_key, "$keyFile", $Course); 68 69 # get the rest of the information from the CGI script 70 my $fileName = param('fileName'); 71 72 # getinformation about the problem set (from the webwork-database) 73 # and begin constructing the environment for constructing and displaying the problem 74 75 &attachProbSetRecord($psvn); 76 77 my $probFolder = getProblemFileName($probNum,$psvn); 78 $probFolder =~ s|/[^/]+$|/|; # trim off the file name 79 $fileName =~ /\.([^.]+)$/; 80 my $fileType = $1; 81 82 83 84 if ($fileType eq 'gif') { 85 my $filePath = "${templateDirectory}$probFolder$fileName"; 86 open(INPUT, "<$filePath")|| print "content-type: text/plain\n\nCan't open $filePath\n"; 87 88 print "content-type: image/gif\n\n"; 89 my $input =""; 90 while (read INPUT, $input, 16384) { 91 print $input; 92 } 93 close(INPUT); 94 } elsif ($fileType eq 'eps') { # this doesn't quite work yet 95 $fileName =~ s/\.eps/\.gif/; # we will read the .gif file and convert it to postscript 96 my $filePath = "${templateDirectory}$probFolder$fileName"; 97 98 open(INPUT, "cat $filePath | /usr/math/bin/giftopnm |/usr/math/bin/pnmtops|")|| print "content-type: text/plain\n\nCan't open $filePath\n"; 99 print "content-type: application/postscript\n\n"; 100 101 my $input =""; 102 while (read INPUT, $input, 16384) { 103 print $input; 104 } 105 close(INPUT); 106 } elsif ($fileType eq 'html') { 107 my $filePath = "${templateDirectory}$probFolder$fileName"; 108 open(INPUT, "<$filePath")|| print "content-type: text/plain\n\nCan't open $filePath\n"; 109 print "content-type: text/html\n\n"; 110 my $input =""; 111 112 while (read INPUT, $input, 16384) { 113 print $input; 114 } 115 close(INPUT); 116 } else { 117 &Global::error("Can't handle |$fileType| filetype yet"); 118 } 119 120 # begin Timing code 121 my $endTime = new Benchmark; 122 &Global::logTimingInfo($beginTime,$endTime,"alias.pl",$Course,$User); 123 # end Timing code 124 exit; 125 126 ### DONE ###
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |