Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/michaelbeeson_old/research/otter-lambda/
Upload File :
Current File : /usr/home/beeson/public_html/michaelbeeson_old/research/otter-lambda/examples.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- DW6 -->
<?php include ('include/head.php'); ?>
<body onmousemove="closesubnav(event);"> 
<?php include ('include/body.php'); 

echo "<div class=\"style1\" id=\"pageName\"> 
    <h2>Examples<img alt=\"small logo\" src=\"logo.jpg\" height=\"59\" width=\"66\"/></h2><br><br>\n";
$directory = $_GET['directory'];
$showfile = $_GET['showfile'];

function safe($t){
// reject parameters put into $showfile by a hacker
$parts = explode(".",$t);
if(count($parts)!=2) 
   return 0;
if(!ctype_alnum($parts[0]) || !ctype_alnum($parts[1]))
   return 0;
return 1;  
}

$legal_examples = array("Algebra",
                       "ExternalSimplification",
                        "FirstOrderLogic",
                        "Induction",
                       "LambdaLogic",
                       "PeanoArithmetic",
                       "SetTheory");
  
if ( !isset($directory) 
    || !in_array($directory,$legal_examples)
   ) {
	echo "<BR><BR><B>Select a category:</b><BR><ul>\n";
	$d = dir("examples/");
	while (false !== ($file = $d->read())) {
		if ( $file == "." or $file == ".." ) continue;
		if ( is_dir("examples/$file") ) {
			echo "<li><a href='examples.php?directory=$file'>$file</a></li>\n";
		}
	}
	echo "</ul>\n";
	$d->close();
} else if ( !isset($showfile) and isset($directory) ) {
	if ( !is_dir("examples/$directory") ) {
		echo "Category $directory does not exist.<br>Please try again.<br>";
		exit();
	}
	$DirectoryWithSpaces =  $directory;  // unCamelCase($directory);
	echo "<center><b>$directoryWithSpaces</b></center><br><br>";
	echo "<center><table border=1>
	      <th>Input File</th><th>Output File</th><th>The Proof</th><th>Commentary</th><th>Date</th>\n";
	$d = dir("examples/$directory");
	while (false !== ($file = $d->read())) {
		if ( $file == "." or $file == ".." ) continue;

		if ( strstr($file,".in") ) {
			echo "<tr><td><a href='examples.php?directory=$directory&showfile=$file'>$file</a></td><td>";
			$filename = substr($file,0,-3);
			$prffile = $filename.".prf";
			$dscfile = $filename.".html";
			$outfile = $filename.".out";
			$theDate = date("r",filemtime("examples/$directory/$file"));
			if ( file_exists("examples/$directory/$outfile") ) {
				echo "<a href='examples.php?directory=$directory&showfile=$outfile'>$outfile</a>";
			}
			echo "</td><td>";
			if ( file_exists("examples/$directory/$prffile") ) {
				echo "<a href='examples.php?directory=$directory&showfile=$prffile'>$prffile</a>";
			}
			echo "</td><td>";
			if ( file_exists("examples/$directory/$dscfile") ) {
				echo "<a href='examples.php?directory=$directory&showfile=$dscfile'>$dscfile</a>";
			}
			echo "</td><td>";
			echo $theDate;
			echo "</td></tr>\n";
		}
	}
	$d->close();
	echo "</table></center><p>&nbsp;</p>\n";
} else  {
    if(!safe($showfile))
        die();
	if ( file_exists("examples/$directory/$showfile") ) {
		if ( strstr($showfile,".in") ) {
			include ('include/functions.php');
			$ItIsAnInput = 1; 
		} else 
			$ItIsAnInput = 0;
       if ( strstr($showfile,".html") ) {
			$ItIsAnHTML = 1; 
		} else 
			$ItIsAnHTML = 0;					
		echo "<b><center>Examples -> $directory -> $showfile</center></b><br><br>";
		$fp = fopen("examples/$directory/$showfile", "rt", $use_include_path);
		$content = "";
		if ($fp) {
			while ( !feof($fp) ) {
				$line = fgets($fp,4096);
//				if ( $ItIsAnInput == 1 ) 
//				    $content .= $line; 
                if($ItIsAnHTML)
				   echo $line;
				else  // for .prf, .in, and .out files
				   { echo htmlspecialchars($line); // replaces quotes, < , etc. by HTML entities
				     echo "<br>";
				   }
			}
			fclose($fp);
			if ( $ItIsAnInput == 1 ) {
				echo "<hr><br>\n";	
				$infile = "examples/$directory/$showfile" ;
				$outfile = "examples/$directory/" . substr($showfile, 0, strlen($showfile)-3) . ".out"; // strip off ".in" and replace with ".out"
				echo "<form method=\"POST\" action=\"otter_simple3.php?infile=$infile&outfile=$outfile\" >" ;
			  //  echo "<INPUT TYPE=\"HIDDEN\" NAME=\"OtterInput\" VALUE=\"$content\">" ;
				echo "<center><input type=\"submit\" value=\"Run this example using Otter-&lambda;\" name=\"B1\"></center>";
				echo "</form>\n";
			}
		} else {
			echo "ERROR: Could not open $showfile.<BR>";
		}
	} else {
		echo "ERROR: $showfile does not exist.<BR>";
	}
}

echo"</div>";   
include ('include/footer.php'); ?>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists