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

  $sSourceDirectory = $_REQUEST['directory'];  
  $sTargetDirectory = $_REQUEST['target'];

  $sSourceDirectory = trim($sSourceDirectory);
  $sTarget = trim($sTargetDirectory);

  $sSourceDirectoryEncoded = htmlspecialchars($sSourceDirectory);
  $sTargetNameEncoded = htmlspecialchars($sTargetDirectory);


  if ($sSourceDirectory == '')
  {
     echo fnRetrovoxStartHtml("No source directory specified");
     echo "
       <br>You didn't specify any source directory from which to
            copy the files";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if ($sTargetDirectory == '')
  {
     echo fnRetrovoxStartHtml("No target directory specified");
     echo "
       <br>You didn't specify any target directory to which to
            copy the files";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if (!file_exists($sSourceDirectory))
  {
     echo fnRetrovoxStartHtml("source directory doesn't exist");
     echo "
       <br>The source directory <em>$sSourceDirectoryEncoded</em>
           doesn't exist
          ";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if (!file_exists($sTargetDirectory))
  {
     echo fnRetrovoxStartHtml("target directory doesn't exist");
     echo "
       <br>The target directory <em>$sTargetDirectoryEncoded</em>
           doesn't exist
          ";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if (!is_dir($sSourceDirectory))
  {
     echo fnRetrovoxStartHtml("source directory isn't a directory");
     echo "
       <br>The source directory <em>$sSourceDirectoryEncoded</em>
           isn't a directory
          ";
     echo fnRetrovoxEndHtml();
     exit;
  }

  if (!is_dir($sTargetDirectory))
  {
     echo fnRetrovoxStartHtml("target directory isn't a directory");
     echo "
       <br>The target directory <em>$sTargetDirectoryEncoded</em>
           isn't a directory
          ";
     echo fnRetrovoxEndHtml();
     exit;
  }
  

//--<--<--<--<--<--<--<--<--<--<--<--<  
?>

<?=fnRetrovoxStartHtml("The directory was copied")?>
The files in a directory called <em><?=$sSourceDirectoryEncoded?></em> will
be copied to the directory <em><?=$sTargetDirectoryEncoded?></em><br>

<?php
//-->-->-->-->-->-->-->-->-->-->-->-->
    if ($dir = opendir($sSourceDirectory))
    {
      //$sDirectoryPathEncoded =
      //   htmlspecialchars($sDirectoryPath);

      while (false !== ($sFileName = readdir($dir)))
      {
        if ($sFileName == ".") continue;
        if ($sFileName == "..") continue;

        $sSourceFilePath = $sSourceDirectory."/".$sFileName;
        $sSourceFilePathEncoded = htmlspecialchars($sSourceFilePath);
        $sTargetFilePath = $sTargetDirectory."/".$sFileName;
        $sTargetFilePathEncoded = htmlspecialchars($sTargetFilePath);


        if (!is_dir($sSourceFilePath))
        {
          copy($sSourceFilePath, $sTargetFilePath);
          echo "
            $sSourceFilePathEncoded  copied to <br>
            $sTargetFilePathEncoded";

        } //-- if 
      } //-- while more files in directory
      closedir($dir);
    }

//--<--<--<--<--<--<--<--<--<--<--<--<  
?>

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