                                    
<?php
//-->-->-->-->-->-->-->-->-->-->-->-->
  $sLibraryPath = '/usr50/home/retrovox/public_html/manage/php-lib';
  include "$sLibraryPath/RETROVOX-CONSTANT-VARIABLES.php";
  include "$sLibraryPath/fnRetrovoxStartHtml.php";
  include "$sLibraryPath/fnRetrovoxEndHtml.php";
  include "$sLibraryPath/fnDirectoryTreeHtmlSelect.php";

  $sParentDirectory = $_REQUEST['directory'];  
  $sDirectoryName = $_REQUEST['name'];

  $sParentDirectory = trim($sParentDirectory);
  $sDirectoryName = trim($sDirectoryName);

  $sParentDirectoryEncoded = htmlspecialchars($sParentDirectory);
  $sDirectoryNameEncoded = htmlspecialchars($sDirectoryName);


  if ($sParentDirectory == '')
  {
     echo fnRetrovoxStartHtml("No parent directory specified");
     echo "
       <br>You didn't specify any parent directory in which the new
           directory would be created.";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if ($sDirectoryName == '')
  {
     echo fnRetrovoxStartHtml("No directory name specified");
     echo "
       <br>You didn't specify any directory name for the new directory
           which was to be created. Every directory needs to have a
           name.";
     echo fnRetrovoxEndHtml();
     exit;
  }

  
  if (!file_exists($sParentDirectory))
  {
     echo fnRetrovoxStartHtml("parent directory doesnt exist");
     echo "
       <br>The parent directory <em>$sParentDirectoryEncoded</em> doesn't exist
           ";
     echo fnRetrovoxEndHtml();
     exit;
  }
  
  if (!is_dir($sParentDirectory))
  {
     echo fnRetrovoxStartHtml("parent directory is not a directory");
     echo "
       <br>The parent directory <em>$sParentDirectoryEncoded</em>
           is not actually a directory. You cannot add sub-directories to 
           files";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if (substr($sParentDirectory, -1) == '/')
  {
     $sParentDirectory = preg_replace('#/$#', '', $sParentDirectory);
  }

  if (substr($sDirectoryName, 0, 1) == '/')
  {
     $sDirectoryName = preg_replace('#^/#', '', $sDirectoryName);
  }

  $sNewDirectoryPath = $sParentDirectory.'/'.$sDirectoryName;
  $sNewDirectoryPathEncoded = htmlspecialchars($sNewDirectoryPath);

  if (is_dir($sNewDirectoryPath))
  {
     echo fnRetrovoxStartHtml("The new directory already exists");
     echo "
       <br>The  directory <em>$sNewDirectoryPathEncoded</em> already
           exists.
           ";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if (!mkdir($sNewDirectoryPath, 0755))
  {
     echo fnRetrovoxStartHtml("The directory could not be created");
     echo "
       <br>The  directory <em>$sNewDirectoryPathEncoded</em> was not able
           to be created. This is probably a problem of permissions
           ";
     echo fnRetrovoxEndHtml();
     exit;
  }
  
//--<--<--<--<--<--<--<--<--<--<--<--<  
?>

<?=fnRetrovoxStartHtml("A new directory was created")?>
A directory called <em><?=$sDirectoryNameEncoded?></em> was created in the
parent directory <em><?=$sParentDirectoryEncoded?></em><br>
The full path to this directory is <em><?=$sNewDirectoryPathEncoded?></em>

<ul>
  <li> </li>
</ul>
  <br>
</body>
</html>
                                    