2 // This function fetches math. images from the data directory
3 // If not, it obtains the corresponding TeX expression from the cache_tex db table
4 // and uses mimeTeX to create the image file
6 $nomoodlecookie = true; // Because it interferes with caching
8 require_once("../../config.php");
10 $CFG->texfilterdir
= "filter/tex";
11 $CFG->teximagedir
= "filter/tex";
13 error_reporting(E_ALL
);
14 $texexp = urldecode($_SERVER['QUERY_STRING']);
15 $texexp = str_replace('formdata=','',$texexp);
18 //$texexp = stripslashes($texexp);
20 $image = md5($texexp) . ".gif";
21 $filetype = 'image/gif';
22 if (!file_exists("$CFG->dataroot/$CFG->teximagedir")) {
23 make_upload_directory($CFG->teximagedir
);
25 $pathname = "$CFG->dataroot/$CFG->teximagedir/$image";
28 system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname -- ". escapeshellarg($texexp) );
33 $texexp = str_replace('"','\"',$texexp);
34 system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname -- \"$texexp\"");
37 system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname -- ". escapeshellarg($texexp) );
40 if (file_exists($pathname)) {
41 $lastmodified = filemtime($pathname);
42 header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
43 header("Expires: " . gmdate("D, d M Y H:i:s", time() +
$lifetime) . " GMT");
44 header("Cache-control: max_age = $lifetime"); // a day
46 header("Content-disposition: inline; filename=$image");
47 header("Content-length: ".filesize($pathname));
48 header("Content-type: $filetype");
49 readfile("$pathname");
51 echo "Image not found!";
59 <head
><title
>mimeTeX Previewer
</title
></head
>
61 <p
>Now enter your own expression
or use the sample provided
,
62 press the Submit button
, and mimeTeX
's rendering should be
63 displayed in the little window immediately below it.
65 <form action="texed.php" method="get"
67 <input type="text" name="formdata" size="50"
68 value="\Large f(x)=\Bigint_{-\infty}^x~e^{-t^2}dt">
71 <iframe name="inlineframe" align="middle" width="80%" height="100">
72 <p>Something is wrong...</p>