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");
9 require_once($CFG->dirroot
.'/filter/tex/lib.php');
11 if (empty($CFG->textfilters
)) {
12 error ('Filter not enabled!');
14 $filters = explode(',', $CFG->textfilters
);
15 if (array_search('filter/tex', $filters) === FALSE) {
16 error ('Filter not enabled!');
20 error_reporting(E_ALL
);
21 $texexp = urldecode($_SERVER['QUERY_STRING']);
22 $texexp = str_replace('formdata=','',$texexp);
25 $image = md5($texexp) . ".gif";
26 $filetype = 'image/gif';
27 if (!file_exists("$CFG->dataroot/filter/tex")) {
28 make_upload_directory("filter/tex");
31 $texexp = str_replace('<','<',$texexp);
32 $texexp = str_replace('>','>',$texexp);
33 $texexp = preg_replace('!\r\n?!',' ',$texexp);
34 $cmd = tex_filter_get_cmd($pathname, $texexp);
35 system($cmd, $status);
37 if (file_exists($pathname)) {
38 send_file($pathname, $image);
40 echo "Image not found!";
44 echo "No tex expresion specified";
50 <head
><title
>mimeTeX Previewer
</title
></head
>
52 <p
>Now enter your own expression
or use the sample provided
,
53 press the Submit button
, and mimeTeX
's rendering should be
54 displayed in the little window immediately below it.
56 <form action="texed.php" method="get"
58 <input type="text" name="formdata" size="50"
59 value="\Large f(x)=\Bigint_{-\infty}^x~e^{-t^2}dt" />
60 <input type="submit" />
62 <iframe name="inlineframe" align="middle" width="80%" height="100">
63 <p>Something is wrong...</p>