make_upload_directory($CFG->algebraimagedir);
}
$pathname = "$CFG->dataroot/$CFG->algebraimagedir/$image";
+ if (file_exists($pathname)) {
+ unlink($pathname);
+ }
$windows = 0;
switch (PHP_OS) {
case "Linux":
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
- system($cmd);
+ system($cmd, $status);
}
if ($texexp && file_exists($pathname)) {
$lastmodified = filemtime($pathname);
readfile("$pathname");
} else {
if (!$windows) {
- $cmd = "$cmd 2>&1";
- echo `$cmd` . "<br>\n";
+ $ecmd = "$cmd 2>&1";
+ echo `$ecmd` . "<br>\n";
+ }
+ echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
+ if ($status == 4) {
+ echo "Status corresponds to illegal instruction<br>\n";
+ } else if ($status == 11) {
+ echo "Status corresponds to bus error<br>\n";
+ } else if ($status == 22) {
+ echo "Status corresponds to abnormal termination<br>\n";
}
echo "Image not found!";
}
$texexp = `$cmd`;
if (preg_match('/parsehilight/',$texexp)) {
$text = str_replace( $matches[0][$i],"<b>Syntax error:</b> " . $texexp,$text);
- } else {
+ } else if ($texexp) {
$texexp = str_replace('#','\not= ',$texexp);
$texexp = str_replace('%','\leq ',$texexp);
$texexp = str_replace('!','\geq ',$texexp);
$texcache->timemodified = time();
insert_record("cache_filters",$texcache);
$text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texexp), $text);
- }
+ } else {
+ $text = str_replace( $matches[0][$i],"<b>Undetermined error:</b> ",$text);
+ }
} else {
$text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text);
}
$texexp = '\Large ' . $texexp;
switch (PHP_OS) {
case "Linux":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp) );
+ $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp);
break;
case "WINNT":
case "WIN32":
case "Windows":
$texexp = str_replace('"','\"',$texexp);
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"");
+ $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"";
break;
case "Darwin":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp) );
+ $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
+ system($cmd, $status);
}
}
header("Content-type: $filetype");
readfile("$pathname");
} else {
+ echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
echo "Image not found!";
}
$texexp = '\Large ' . $texexp;
switch (PHP_OS) {
case "Linux":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp) );
+ $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.linux -e $pathname ". escapeshellarg($texexp);
break;
case "WINNT":
case "WIN32":
case "Windows":
$texexp = str_replace('"','\"',$texexp);
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"");
+ $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.exe -e $pathname \"$texexp\"";
break;
case "Darwin":
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp) );
- break;
- default:
- system("$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp) );
+ $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
+ system($cmd, $status);
}
}
header("Content-type: $filetype");
readfile("$pathname");
} else {
+ echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
echo "Image not found!";
}
make_upload_directory($CFG->teximagedir);
}
$pathname = "$CFG->dataroot/$CFG->teximagedir/$image";
+ if (file_exists($pathname)) {
+ unlink($pathname);
+ }
$windows = 0;
switch (PHP_OS) {
case "Linux":
$cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin -e $pathname ". escapeshellarg($texexp);
break;
}
- system($cmd);
+ system($cmd, $status);
}
if ($texexp && file_exists($pathname)) {
$lastmodified = filemtime($pathname);
readfile("$pathname");
} else {
if (!$windows) {
- $cmd = "$cmd 2>&1";
- echo `$cmd` . "<br>\n";
+ $ecmd = "$cmd 2>&1";
+ echo `$ecmd` . "<br>\n";
+ }
+ echo "The shell command<br>$cmd<br>returned status = $status<br>\n";
+ if ($status == 4) {
+ echo "Status corresponds to illegal instruction<br>\n";
+ } else if ($status == 11) {
+ echo "Status corresponds to bus error<br>\n";
+ } else if ($status == 22) {
+ echo "Status corresponds to abnormal termination<br>\n";
}
echo "Image not found!";
}