libdir.'/filelib.php'); require_once($CFG->dirroot.'/filter/tex/lib.php'); require_once($CFG->dirroot.'/filter/tex/latex.php'); $cmd = ''; // Initialise these variables $status = ''; $relativepath = get_file_argument(); $args = explode('/', trim($relativepath, '/')); if (count($args) == 1) { $image = $args[0]; $pathname = $CFG->dataroot.'/filter/tex/'.$image; } else { print_error('invalidarguments', 'error'); } if (!file_exists($pathname)) { $md5 = str_replace(".{$CFG->filter_tex_convertformat}",'',$image); if ($texcache = $DB->get_record('cache_filters', array('filter'=>'tex', 'md5key'=>$md5))) { if (!file_exists($CFG->dataroot.'/filter/tex')) { make_upload_directory('filter/tex'); } // try and render with latex first $latex = new latex(); $density = $CFG->filter_tex_density; $background = $CFG->filter_tex_latexbackground; $texexp = $texcache->rawtext; // the entities are now decoded before inserting to DB $latex_path = $latex->render($texexp, $md5, 12, $density, $background); if ($latex_path) { copy($latex_path, $pathname); $latex->clean_up($md5); } else { // failing that, use mimetex $texexp = $texcache->rawtext; $texexp = str_replace('<', '<', $texexp); $texexp = str_replace('>', '>', $texexp); $texexp = preg_replace('!\r\n?!', ' ', $texexp); $texexp = '\Large '.$texexp; $cmd = filter_tex_get_cmd($pathname, $texexp); system($cmd, $status); } } } if (file_exists($pathname)) { send_file($pathname, $image); } else { if (debugging()) { echo "The shell command
$cmd
returned status = $status
\n"; echo "Image not found!
"; echo "Please try the wwwroot/filter/tex/texdebug.php\">debugging script"; } else { echo "Image not found!
"; echo "Please try the wwwroot/filter/tex/texdebug.php\">debugging script
"; echo "Please turn on debug mode in site configuration to see more info here."; } }