[Aimmath-commit] moodle/mod/math_assignment pdfgen.php,1.11,1.12
Brought to you by:
gustav_delius,
npstrick
From: <gus...@us...> - 2003-09-28 19:26:34
|
Update of /cvsroot/aimmath/moodle/mod/math_assignment In directory sc8-pr-cvs1:/tmp/cvs-serv10123/mod/math_assignment Modified Files: pdfgen.php Log Message: removed file_get_contents which requires php 4.3. Also hacked temporary file creation. Index: pdfgen.php =================================================================== RCS file: /cvsroot/aimmath/moodle/mod/math_assignment/pdfgen.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pdfgen.php 27 Sep 2003 20:14:37 -0000 1.11 --- pdfgen.php 28 Sep 2003 19:26:18 -0000 1.12 *************** *** 118,122 **** if (math_assignment_is_tex_file($texfile)) { ! $latex = file_get_contents($texfile); foreach ($questions as $question) { $latex = str_replace_once("\aimquestion","$\\sphericalangle$ ".math_assignment_aim_to_latex($question,$type),$latex); --- 118,122 ---- if (math_assignment_is_tex_file($texfile)) { ! $latex = implode ('', file($texfile)); foreach ($questions as $question) { $latex = str_replace_once("\aimquestion","$\\sphericalangle$ ".math_assignment_aim_to_latex($question,$type),$latex); *************** *** 124,128 **** } else { ! $latex = file_get_contents("$CFG->dirroot/mod/math_assignment/$type.tex"); foreach ($questions as $question) { $latex .= "\n\n\\nextq $\\sphericalangle$ ".math_assignment_aim_to_latex($question,$type); --- 124,128 ---- } else { ! $latex = implode ('', file("$CFG->dirroot/mod/math_assignment/$type.tex")); foreach ($questions as $question) { $latex .= "\n\n\\nextq $\\sphericalangle$ ".math_assignment_aim_to_latex($question,$type); *************** *** 138,149 **** // 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 --- 138,150 ---- // generate pdf file from $latex ! $tempfile = substr(md5(microtime()), 0, 8); 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 $tempfile.tex"); ! @unlink("$tempfile.tex"); ! @unlink("$tempfile.aux"); ! @unlink("$tempfile.log"); // output of pdf *************** *** 151,155 **** /* 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: --- 152,156 ---- /* 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("$tempfile.pdf"); /* I have just noticed the following in the php documentation on this issue of using Content-disposition headers: *************** *** 161,166 **** 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 --- 162,167 ---- 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("$tempfile.pdf", "rb")) { // the 'b' is for compatibility with Windoze // tell the browser that it is pdf *************** *** 177,181 **** } ! @unlink("$tempnam.pdf"); function math_assignment_aim_to_latex($data,$type) { --- 178,183 ---- } ! @unlink("$tempfile.pdf"); ! */ function math_assignment_aim_to_latex($data,$type) { |