[Aimmath-commit] moodle/mod/math_assignment pdfgen.php,1.10,1.11
Brought to you by:
gustav_delius,
npstrick
From: <ma...@us...> - 2003-09-27 22:30:23
|
Update of /cvsroot/aimmath/moodle/mod/math_assignment In directory sc8-pr-cvs1:/tmp/cvs-serv13607/mod/math_assignment Modified Files: pdfgen.php Log Message: Implemented the generation of unique temporary file names. Index: pdfgen.php =================================================================== RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/pdfgen.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pdfgen.php 27 Sep 2003 09:19:27 -0000 1.10 --- pdfgen.php 27 Sep 2003 20:14:37 -0000 1.11 *************** *** 138,155 **** // generate pdf file from $latex ! //$tempfile = tempnam(); ! $tempfile = "temp.tex"; ! if (!$fp=fopen($tempfile,"w")) error("Sorry, I can't produce the pdf output. Failed to open temporary file."); fwrite($fp,$latex); fclose($fp); ! exec("pdflatex -interaction=batchmode temp.tex"); // output of pdf ! redirect("temp.pdf"); ! /* ! if ($file = fopen("temp.pdf", "rb")) { // the 'b' is for compatibility with Windoze // tell the browser that it is pdf --- 138,166 ---- // generate pdf file from $latex ! if (!$tempfile = tempnam("/tmp", "pdfsheet")) ! error("Sorry, I can't produce the pdf output. Failed to open temporary file."); ! if (!$fp=fopen("$tempfile.tex","wb")) error("Sorry, I can't produce the pdf output. Failed to open temporary file."); fwrite($fp,$latex); fclose($fp); ! exec("pdflatex -interaction=batchmode $tempfile.tex"); ! @unlink("$tempnam.tex"); // output of pdf ! /* We need to remove the temporary file so we had better output it to the browser directly rather than redirecting. ! If we redirect we have no idea when the file is no longer needed. */ ! //redirect("$tempnam.pdf"); ! /* I have just noticed the following in the php documentation on this issue of using Content-disposition headers: ! Note: There is a bug in Microsoft Internet Explorer 4.01 that prevents this from working. There is no workaround. ! There is also a bug in Microsoft Internet Explorer 5.5 that interferes with this, which can be resolved by upgrading ! to Service Pack 2 or later. ! Darn MS! ! One possible way round this might be to use slash arguments with the last arguent 'problems.pdf' when a ! problem sheet is required and 'solutions.pdf' when solutions are required. With luck this might fool IE which seems to ! go by the extension when it ignores the headers. This would need testing in a broken version of IE. */ ! ! if ($file = fopen("$tempnam.pdf", "rb")) { // the 'b' is for compatibility with Windoze // tell the browser that it is pdf *************** *** 166,170 **** } ! */ function math_assignment_aim_to_latex($data,$type) { --- 177,181 ---- } ! @unlink("$tempnam.pdf"); function math_assignment_aim_to_latex($data,$type) { |