Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 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 5 6 // disable moodle specific debug messages and any errors in output 7 define('NO_DEBUG_DISPLAY', true); 8 define('NO_MOODLE_COOKIES', true); // Because it interferes with caching 9 10 require_once('../../config.php'); 11 12 if (!filter_is_enabled('algebra')) { 13 print_error('filternotenabled'); 14 } 15 16 require_once($CFG->libdir.'/filelib.php'); 17 require_once($CFG->dirroot.'/filter/tex/lib.php'); 18 19 $cmd = ''; // Initialise these variables 20 $status = ''; 21 22 $relativepath = get_file_argument(); 23 24 $args = explode('/', trim($relativepath, '/')); 25 26 if (count($args) == 1) { 27 $image = $args[0]; 28 $pathname = $CFG->dataroot.'/filter/algebra/'.$image; 29 } else { 30 print_error('invalidarguments', 'error'); 31 } 32 33 if (!file_exists($pathname)) { 34 $md5 = str_replace('.gif','',$image); 35 if ($texcache = $DB->get_record('cache_filters', array('filter'=>'algebra', 'md5key'=>$md5))) { 36 if (!file_exists($CFG->dataroot.'/filter/algebra')) { 37 make_upload_directory('filter/algebra'); 38 } 39 40 $texexp = $texcache->rawtext; 41 $texexp = str_replace('<','<',$texexp); 42 $texexp = str_replace('>','>',$texexp); 43 $texexp = preg_replace('!\r\n?!',' ',$texexp); 44 $texexp = '\Large ' . $texexp; 45 $cmd = filter_tex_get_cmd($pathname, $texexp); 46 system($cmd, $status); 47 } 48 } 49 50 if (file_exists($pathname)) { 51 send_file($pathname, $image); 52 } else { 53 if (debugging()) { 54 echo "The shell command<br />$cmd<br />returned status = $status<br />\n"; 55 echo "Image not found!<br />"; 56 echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a>"; 57 } else { 58 echo "Image not found!<br />"; 59 echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a><br />"; 60 echo "Please turn on debug mode in site configuration to see more info here."; 61 } 62 } 63
title
Description
Body
title
Description
Body
title
Description
Body
title
Body