# publicmoodle/moodle mirrored from git://git.moodle.org/moodle.git

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

file 196 lines (186 sloc) 7.8 kb
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 texfilterdir = "filter/tex";    $CFG->teximagedir = "filter/tex"; error_reporting(E_ALL);$query = urldecode($_SERVER['QUERY_STRING']); if ($query) {      $output =$query;      $splitpos = strpos($query,'&')-4;      $texexp = substr($query,4,$splitpos);$md5 = md5($texexp); if (strpos($query,'ShowDB') || strpos($query,'DeleteDB')) {$texcache = get_record("cache_filters","filter","tex", "md5key", $md5); } if (strpos($query,'ShowDB')) {        if ($texcache) {$output = "DB cache_filters entry for $texexp\n";$output .= "id = $texcache->id\n";$output .= "filter = $texcache->filter\n";$output .= "version = $texcache->version\n";$output .= "md5key = $texcache->md5key\n";$output .= "rawtext = $texcache->rawtext\n";$output .= "timemodified = $texcache->timemodified\n"; } else {$output = "DB cache_filters entry for $texexp not found\n"; } } if (strpos($query,'DeleteDB')) {        if ($texcache) {$output = "Deleting DB cache_filters entry for $texexp\n";$result = delete_records("cache_filters","id",$texcache->id); if ($result) { $result = 1; } else {$result = 0;          }          $output .= "Number of records deleted =$result\n";        } else {          $output = "Could not delete DB cache_filters entry for$texexp\nbecause it could not be found.\n";        }      }      if (strpos($query,'ShowImage')) { tex2image($texexp);      } else {         outputText($output); } exit; }function outputText($texexp) {  header("Content-type: text/html");  echo "
\n";  if ($texexp) {$texexp = str_replace('<','<',$texexp);$texexp = str_replace('>','>',$texexp);$texexp = str_replace('"','"',$texexp); echo "$texexp\n\n";  } else {    echo "No text output available\n\n";  }  echo "
\n";}function tex2image($texexp) { global$CFG;  if ($texexp) {$texexp = '\Large ' . $texexp;$lifetime = 86400;       $image = md5($texexp) . ".gif";       $filetype = 'image/gif'; if (!file_exists("$CFG->dataroot/$CFG->teximagedir")) { make_upload_directory($CFG->teximagedir);       }       $pathname = "$CFG->dataroot/$CFG->teximagedir/$image";       $windows = 0; switch (PHP_OS) { case "Linux":$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp);       break;       case "WINNT":       case "WIN32":       case "Windows":           $windows = 1;$texexp = str_replace('"','\"',$texexp);$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\""; break; case "Darwin": $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e$pathname ". escapeshellarg($texexp); break; } system($cmd); } if ($texexp && file_exists($pathname)) { $lastmodified = filemtime($pathname); header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"); header("Expires: " . gmdate("D, d M Y H:i:s", time() +$lifetime) . " GMT"); header("Cache-control: max_age = $lifetime"); // a day header("Pragma: "); header("Content-disposition: inline; filename=$image"); header("Content-length: ".filesize($pathname)); header("Content-type:$filetype"); readfile("$pathname"); } else { if (!$windows) { $cmd = "$cmd 2>&1"; echo $cmd . " \n"; } echo "Image not found!"; }}?>TeX Filter Debuggerdirroot/filter/tex/pix.php";$PHP_OS = PHP_OS; $handle = fopen($filename,"r"); $contents = fread($handle, filesize($filename)); fclose($handle); if (!strpos($contents,'case "'.$PHP_OS . '":')) { echo "WARNING! case \"$PHP_OS\": NOT found in pix.php!!! "; }?> Please enter an algebraic expression without any surrounding$\$ into the text box below. (Click here for help.)

1. First click on this button                to see the cache_filters database entry for this expression.
2. If the database entry looks corrupt, click on this button to delete it:
3.
4. Finally click on this button                to show a graphic image of the algebraic expression.
5.

Debugging Help

First a brief overview of how the TeX filter works. The TeX filter firstsearches the database cache_filters table to see if this TeX expression had beenprocessed before. If not, it adds a DB entry for that expression. It thenreplaces the TeX expression by an <img src=".../filter/tex/pix.php...">tag. The filter/tex/pix.php script then searches the database to find anappropriate gif image file for that expression and to create one if it doesn't exist.Here are a few common things that can go wrong and some suggestions on howyou might try to fix them.

1. Something had gone wrong on a previous occasion when the filter tried toprocess this expression. Then the database entry for that expression containsa bad TeX expression in the rawtext field (usually blank). You can fix thisby clicking on "Delete DB Entry"
2. The TeX to gif image conversion process does not work. If your server isrunning Unix, a likely cause is that the mimetex binary you are using isincompatible with your operating system. You can try compiling it from theC sources downloaded from http://www.forkosh.com/mimetex.zip, or looking for an appropriatebinary at http://moodle.org/download/mimetex/. You may then also need toedit your moodle/filter/tex/pix.php file to add

to the list of operating systemsin the switch (PHP_OS) statement. Windows users may have a problem properlyunzipping mimetex.exe. Make sure that mimetex.exe is is PRECISELY328192 bytes in size. If not, download a fresh copy fromhttp://moodle.org/download/mimetex/windows/mimetex.exe. Another possible problem which may affectboth Unix and Windows servers is that the web server doesn't have execute permissionon the mimetex binary. In that case change permissions accordingly

Something went wrong with that request. Please try again.