diff --git a/filter/algebra/algebradebug.php b/filter/algebra/algebradebug.php
index ddbe11f8e20..caff0f63115 100644
--- a/filter/algebra/algebradebug.php
+++ b/filter/algebra/algebradebug.php
@@ -236,10 +236,15 @@ function tex2image($texexp, $md5) {
}
if (file_exists($commandpath)) {
echo "File size of mimetex executable $commandpath is " . filesize($commandpath) . "
";
- $handle = fopen($commandpath,"rb");
- $contents = fread($handle,16384);
- fclose($handle);
- echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "
";
+ echo "The file permissions are: " . decoct(fileperms($commandpath)) . "
";
+ if (function_exists("md5_file")) {
+ echo "The md5 checksum of the file is " . md5_file($commandpath) . "
";
+ } else {
+ $handle = fopen($commandpath,"rb");
+ $contents = fread($handle,16384);
+ fclose($handle);
+ echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "
";
+ }
} else {
echo "mimetex executable $commandpath not found!
";
}
diff --git a/filter/tex/texdebug.php b/filter/tex/texdebug.php
index 32426976589..13b846421ce 100644
--- a/filter/tex/texdebug.php
+++ b/filter/tex/texdebug.php
@@ -147,10 +147,15 @@ function tex2image($texexp) {
}
if (file_exists($commandpath)) {
echo "File size of mimetex executable $commandpath is " . filesize($commandpath) . "
";
- $handle = fopen($commandpath,"rb");
- $contents = fread($handle,16384);
- fclose($handle);
- echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "
";
+ echo "The file permissions are: " . decoct(fileperms($commandpath)) . "
";
+ if (function_exists("md5_file")) {
+ echo "The md5 checksum of the file is " . md5_file($commandpath) . "
";
+ } else {
+ $handle = fopen($commandpath,"rb");
+ $contents = fread($handle,16384);
+ fclose($handle);
+ echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "
";
+ }
} else {
echo "mimetex executable $commandpath not found!
";
}