Sindbad~EG File Manager
<?php
$OutputDir = "otter/projects/";
$InputDir = "otter/projects/";
$ExampleDir = "examples/";
$OtterDir = "otter"; // Otter or Otter-lambda executable file location.
$ExecuteLocation = "$OtterDir\\otter2.exe"; // or Otter-lambda
$inputfile = "";
$outputfile = "";
function GenerateFileName()
{ // Each time this function is called it generates a unique new name.
$name = "otter-".time();
return $name;
}
function RunOtterByText($text)
{
global $InputDir, $OutputDir, $inputfile, $outputfile;
$Filename = GenerateFileName();
$inputfile = $InputDir.$Filename.".in";
$outputfile = $OutputDir.$Filename.".out";
file_write($inputfile,$text); // $OtterInput comes from the HTML form.
return RunOtterByFile($inputfile,$outputfile);
}
function RunOtterByFile($infile,$outfile)
{
global $ExecuteLocation;
$Execute = $ExecuteLocation." <".$infile." >".$outfile;
exec($Execute);
return file_read($outfile);
}
function file_write($filename, $data)
{ echo("Trying to open $filename");
$fh = fopen($filename, "wt");
if ( !$fh ) {
echo "ERROR: Could not open the file for writing.<BR>";
exit();
}
$bytes_written = fwrite($fh, $data);
fclose($fh);
$bytes_written;
}
function file_read($filename, $use_include_path = 0)
{
$successful = 0;
$file = fopen($filename, "rt", $use_include_path);
if ($file) {
while ( !feof($file) ) {
$line = fgets($file,4096);
if ( strstr($line,"PROOF") )
echo "<B><font color=#0000ff>";
echo "$line<br>";
if ( strstr($line,"end of proof") )
echo "</B></font>";
}
$successful = 1;
fclose($file);
} else {
echo "ERROR: Could not open the file for reading.<BR>";
exit();
}
return $successful;
}
function print_last($inputf,$outputf)
{
echo "<HR><table width=\"700\" border=\"0\" align=\"center\">
<tr>
<td><a href=\"$inputf\">Download The Input File</a></td>
<td><a href=\"$outputf\">Download The Output File</a></td>
</tr>
</table><BR>";
}
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists