                                                                                                                                                                    <?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
//--Script Description:
//--  This script is designed to do the work of updating a 
//--  users password in the Apache 'htpasswd' file. This file is
//--  normally going to be located in the 'manage' directory of the 
//--  installation of the 'webpad' system, which in the case of the
//--  wagga-cwc.org.au server is currently called 'refurb/manage/'.
//--
//--  Generally it is not a good idea to put this file in any 
//--  web-accessible directory, however the 'manage' directory should
//--  itself always be password protected, even if the authentication
//--  process is only 'basic' and thus not particularly good.
//--
//--  


  include "/home/waggacwc/public_html/refurb/RETRO-GLOBALS.php";
  //test
  include "$LIBRARYPATH/RETROVOX-CONSTANT-VARIABLES.php";
  include "$LIBRARYPATH/fnRetrovoxStartHtml.php";
  include "$LIBRARYPATH/fnStartHtml.php";
  include "$LIBRARYPATH/fnSwitchFileSelect.php";
  include "$LIBRARYPATH/fnDebugArray.php";
  include "$LIBRARYPATH/fnDirectoryListing.php";

  $bRenameFileTrick = false;

  $sPasswordFilePath = $_REQUEST['password-file'];
  $sPasswordFilePath = trim($sPasswordFilePath);
  $sPasswordFilePathEncoded = 
    htmlspecialchars($sPasswordFilePath);

  $sUserName = $_REQUEST['user-name'];
  $sUserName = trim($sUserName);
  $sUserNameEncoded = htmlspecialchars($sUserName);
  $sUserNameUrlEncoded = 
    htmlspecialchars(urlencode($sUserName));

  $sNewPassword = $_REQUEST['new-password'];
  $sNewPassword = trim($sNewPassword);
  $sNewPasswordEncoded = htmlspecialchars($sNewPassword)
  $sNewPasswordUrlEncoded = 
    htmlspecialchars(urlencode($sNewPassword));

  $sNewPasswordConfirm = $_REQUEST['new-password-confirm'];
  $sNewPasswordConfirm = trim($sNewPasswordConfirm);

  if ($sPasswordFilePath == "")
  {
    //-- This needs to be elaborated, 
    echo "No password file specified";
    exit;
  } //-- no password file specified

  if (!file_exists($sPasswordFilePath))
  {
    echo "The password file doesnt exist";
    exit;
  } //-- password file doesn't exist


  if (is_dir($sPasswordFilePath))
  {
    echo "The password file is a directory";
    exit;
  } //-- password file is a directory

  if (!is_writable($sPasswordFilePath))
  {
    rename($sPasswordFilePath, "$sPasswordFilePath-temp");
    rename("$sPasswordFilePath-temp", $sPasswordFilePath);

    if (is_writable($sPasswordFilePath))
    {
      $bRenameFileTrick = true;
    }
    else
    {
      echo "The password file is not writable and 
            the rename trick did not work";
      exit;
    }
  } //-- password file is not writable



  $debug = "";
  if ($debug == "true")
  {
    echo "
      <pre>
      </pre>";
    //exit;
  } //--if


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

<!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='<?=ORGANISATIONNAME?>, edit, file'>
 <META HTTP-EQUIV='Description'
          CONTENT='Update User Password'>
        <LINK REV='made' HREF='mailto:matth3wbishop@yahoo.com'>

<head><title>Update user password for <?=$ORGANISATIONNAME?></title>
<style>
  TEXTAREA
  {
    background: black;
    font-size: <?=$iEditorFontSize?>pt;
    color: white;
    font-weight: normal;
  }
</style>
</head>
   <body bgcolor='lightgreen'>
<center><h3>Update User Password</h3></center>
    
</body>
</html>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    


                                                                                                                                                                                                                                                                                                                                                                        
        
                                                                                                        
                                                                                    