

<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
   
  $sFilePath = '';

  $sFilePath = $_GET['file-name'];
  $sFilePathEncoded = htmlspecialchars($sFilePath);
  $sWebFilePathEncoded = htmlspecialchars(str_replace("public_html", "", $sFilePath));

  $sChmodMode = $_GET['chmod-mode'];
  $sChmodModeEncoded = htmlspecialchars($sChmodMode);

  

  if (substr($sFilePath, 0, 1) != "/")
  {
    $sFilePath = "/$sFilePath";  
  }
  
  if (!strstr($sFilePath, "/usr50/home/retrovox"))
  {
    $sFilePath = "/usr50/home/retrovox".$sFilePath;
  }
  

  $bStripSlashes = $_GET['stripslash'];

  if ($sFilePath == '/usr50/home/retrovox')
  {
    echo "
      <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'>
      <html>
       <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'>
       <META HTTP-EQUIV='Keywords'
		CONTENT='Retrovox, edit, file, unspecified'>
       <META HTTP-EQUIV='Description'
		CONTENT='Retrovox notepad, file-name unspecified'>
	      <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'>

      <head><title>Retrovox Copy File (No file name specified)</title>
      </head>
      <body>
      <center><h1>No file name specified</h1></center>
	  <p>You did not specify any file to be edited</p>
          <br>
          <ol>
           <li><a href = 'move-file-form.php'>
	   Try Again</a></li>
          </ol>
	  
      </body>
      </html>";
     exit; 
  } //-- if no file specified
 
  
  /*
  if (is_dir($sFilePath))
  {
    if (substr($sFilePath, -1) != "/")
    {
      $sFilePath = "$sFilePath/";
    }
    
    echo "
      <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'>
      <html>
       <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'>
       <META HTTP-EQUIV='Keywords'
		CONTENT='Retrovox, edit, file, directory'>
       <META HTTP-EQUIV='Description'
		CONTENT='Retrovox notepad, the path is a directory'>
	      <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'>

      <head><title>Retrovox Notepad, (The path is a directory)</title>
      </head>
      <body>
      <center><h1>The path is a directory</h1></center>
	  <p>
          The file-name [$sFilePathEncoded] which you just specified is a directory (folder).
          The Retrovox Notepad system is for editing text files located on the
          server. 
          </p>
          <br>
          <ol>
           <li><a href = \"move-file-form.php?file=$sFilePathEncoded\">
	   Re-enter the file name</a></li>
          </ol>
	  <ol>";
	  
      $dh  = opendir($sFilePath);
      while (false !== ($sMemberFileName = readdir($dh)))
      {
        echo "<li><a href ='move-file-form.php?file=".
	  htmlspecialchars(urlencode($sFilePath.$sMemberFileName))
	  ."'>$sFilePath$sMemberFileName</a></li> \n";
      }
      echo "  
        </ol>
        </body>
        </html>";
      
     return;
  } //-- if file is a directory
  */


  /*
  if (!is_writable($sFilePath))
  {
    echo "
      <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'>
      <html>
       <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'>
       <META HTTP-EQUIV='Keywords'
		CONTENT='Retrovox, edit, file, unwritable'>
       <META HTTP-EQUIV='Description'
		CONTENT='Retrovox notepad, file unwritable'>
	      <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'>

      <head><title>Retrovox Notepad, (File is not writable)</title>
      </head>
      <body>
      <center><h1>The file is not writable</h1></center>
	  <p>
          The file-name [$sFilePathEncoded] which you just specified has its permissions
          set so that is cannot be edited (updated or modified in any way).
          You can overcome this problem by typing 
          <pre>
            chmod a+w $sFilePath
          </pre>
          when you are logged into the retrovox server.
          </p>
          <br>
          <ol>
           <li><a href = 'retrovox-notepad-choose-file.html'>Re-enter the file name</a></li>
          </ol>
           
      </body>
      </html>";
      return; 
  } //-- if file not writeable
  */

  if (!file_exists($sFilePath))
  {
    echo "
      <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'>
      <html>
       <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'>
       <META HTTP-EQUIV='Keywords'
		CONTENT='Retrovox, edit, file, not exist'>
       <META HTTP-EQUIV='Description'
		CONTENT='Retrovox notepad, file does not exist'>
	      <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'>

      <head><title>Retrovox Notepad, (File does not exist)</title>
      </head>
      <body>
      <center><h1>The file does not exist</h1></center>
	  <p>
          The file-name [$sFilePathEncoded] which you just specified does
	  not exist and therefore cannot be copied or renamed
          </p>
          <br>
          <ol>
           <li><a href = \"move-file-form.php?file=$sFilePathEncoded\">
	   Re-enter the file name</a></li>
          </ol>
           
      </body>
      </html>";
      exit; 
	  
  }
  else
  {
     $bSuccess = chmod($sFilePath, $sChmodMode);
  } 

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

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'>
<html>
 <META HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET='iso-8859-1'>
 <META HTTP-EQUIV='Keywords'
          CONTENT='Retrovox, chmod, file'>
 <META HTTP-EQUIV='Description'
          CONTENT='Retrovox chmod file'>
        <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'>

<head><title>Retrovox chmod file</title>
</head>
<body>
<center><h1>The Retrovox move file</h1></center>
<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
  if ($bSuccess)
  {
    echo "<p>The file $sFilePathEncoded was chmoded to $sChmodModeEncoded</p>";
  }
  else
  {
    echo "<p>The file $sFilePathEncoded could NOT be chmoded to $sChmodModeEncoded</p>";
  }
//--<--<--<--<--<--<--<--<--<--<--<--<--<--<
?>
    <ol>
           <li><a href = "move-file-form.php?file=<?=$sFilePathEncoded?>">
	   Chmod again</a></li>
    </ol>
    <br>
</body>
</html>



