                                                                                                                                                                            

<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
  include "c:/apache2/htdocs/RETRO-GLOBALS.php";

  include "$LIBRARYPATH/RETROVOX-CONSTANT-VARIABLES.php";
  include "$LIBRARYPATH/fnRetrovoxStartHtml.php";
  include "$LIBRARYPATH/fnRetrovoxDirectoryListing.php";

  $sWebPrefixPath = $WEBDOCUMENTROOT;

  $bNewFile = false;
  $sFilePath = '';
  $sFileName = $_GET['file'];

  $sFilePathEncoded = htmlspecialchars($sFilePath);
  $sFilePathUrlEncoded = htmlspecialchars(urlencode($sFilePath));
  $sWebFilePathEncoded = htmlspecialchars(str_replace("public_html", "", $sFilePath));

  
  if ($sFileName == '')
  {
    echo fnRetrovoxStartHtml("No file name was specified");
    echo "
     <p>You did not specify any file to be searched for</p>
     <br>
     <a href = 'find-file-form.php'>
          Re-enter the file name to seach for</a>
     </body>
     </html>";
     exit; 
  } //-- if no file specified
 

  $sBaseDirectory = $WEBDOCUMENTROOT;
  //-- The find command is Unix specific
  //$sCommandResult = 
  //  shell_exec(
  //    'find '.$sBaseDirectory.' -iname "*'.$sFileName.'*" -print 2>&1');

  //-- The code below is Microsoft specific
  $sCommandResult =
    shell_exec('dir /s /b c:\\apache2\\htdocs\\ | find "'.$sFileName.'"');
  //$sCommandResult = $sCommandResult. 
  //  shell_exec('help find');
  //$sCommandResult = $sCommandResult.
  //  shell_exec('help dir');
  
  //echo "<pre>$sCommandResult</pre>";
  //exit;
  $sCommandResult = preg_replace("/\n\s*\n/", "\n", $sCommandResult);
  $aaCommandResults = explode("\n", $sCommandResult);
  sort($aaCommandResults);
    
//--<--<--<--<--<--<--<--<--<--<--<--<--<--<
?>

<?=fnRetrovoxStartHtml("Find file results")?>

  <strong>The search for the file name <em><?=$sFileName?></em>
          returned the following results:</strong><br>

<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
  foreach ($aaCommandResults as $sFilePath)
  {
    $sFilePath = trim($sFilePath);
    $sFilePath = str_replace('\\', '/', $sFilePath);
    $sFilePath = preg_replace('#[/]+#', '/', $sFilePath);

    $sWebFilePathEncoded = 
       htmlspecialchars(str_replace($sWebPrefixPath, '', $sFilePath));
    $sFilePathEncoded = 
       htmlspecialchars(urlencode($sFilePath));
    
    //-- It seems silly to try and guess what might be a text file
    //$sTextFileNameExtensions =
    //  '(\.php$|\.css|\.txt$|\.asp$|\.java$|\.js$|\.xml$|\.cgi$|\.pl|\.c|\.html?$)';
    $sTextFileNameExtensions = '.';

    if (preg_match("/$sTextFileNameExtensions/i", $sFilePath))
    {
      echo "
        $sFilePath (<a href = '$sWebFilePathEncoded'>view</a> |
        <a href = '$MANAGEMENTWEBFOLDER/move-file-form.php?".
        "file=$sFilePathEncoded'>copy</a> |
        <a href = '$MANAGEMENTWEBFOLDER/move-file-form.php?".
        "file=$sFilePathEncoded'>rename</a> |
        <a href = '$MANAGEMENTWEBFOLDER/notepad/retrovox-notepad.php?".
        "file=$sFilePathEncoded'>edit</a>)<br>";
    }
    else
    {
      echo "
        $sFilePath (<a href = '$sWebFilePathEncoded'>view</a> |
        <a href = '$MANAGEMENTWEBFOLDER/move-file-form.php?".
        "file=$sFilePathEncoded'>copy</a> |
        <a href = '$MANAGEMENTWEBFOLDER/move-file-form.php?".
        "file=$sFilePathEncoded'>rename</a>)<br>";
    } //-- if file is a text file
    
  } //-- foreach

//--<--<--<--<--<--<--<--<--<--<--<--<--<--<
?>
 
</body>
</html>



                                                                                                                                                                            