fmath is an extremely powerful plug-in library for wysiwyg editors.
It provides an editor for mathematical formulas, which generates images that can be used in drupal sites. It processes mathml and latex.
There is a problem though, images are saved on a server using the following php file.
if($_POST["save"]){
$type = $_POST["type"];
if($_POST["name"] and ($type=="JPG" or $type=="PNG")){
$img = base64_decode($_POST["image"]);
$myFile = "img/".$_POST["name"].".".$type ;
$fh = fopen($myFile, 'w');
fwrite($fh, $img);
fclose($fh);
echo "http://your_server/capture/img/".$_POST["name"].".".$type;
}
}else{
header('Content-Type: image/jpeg');
echo base64_decode($_POST["image"]);
}
This file is publicly available, and can not be restricted with .htaccess to localhost only (the whole library will not work).
From my understanding the file is called by scripts on a user side via an url, and the image is passed by the POST method. That makes the file very dangerous as it allows anyone to save anything on the server.
Are my suspicions correct? How can I make this safe to use?
The whole library weights 11MB so I don't feel like debugging it.