                                                                                                                                                                                                                                                    <?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->
//--Description:
//--  The purpose of this script is to allow the user of the 
//--  webpad system to select a document to edit. A document is a plain
//--  text file without any special markup, which can be transformed into
//--  HTML using regular expressions
//--
  include "/home/waggacwc/public_html/refurb/RETRO-GLOBALS.php";
  //test1
  include "$LIBRARYPATH/RETROVOX-CONSTANT-VARIABLES.php";
  include "$LIBRARYPATH/fnRetrovoxStartHtml.php";
  include "$LIBRARYPATH/fnStartHtml.php";
  include "$LIBRARYPATH/fnSwitchFileSelect.php";
  include "$LIBRARYPATH/fnNumericHtmlSelect.php";
  include "$LIBRARYPATH/fnDebugArray.php";
  include "$LIBRARYPATH/fnDirectoryListing.php";
  include "$LIBRARYPATH/fnArrayToHtmlLinkList.php";


  include "$LIBRARYPATH/fnFillWebTemplate.php";
  include "$LIBRARYPATH/fnMessageToHtml.php";
  include "$LIBRARYPATH/fnListBlockToHtml.php";
  include "$LIBRARYPATH/fnCodeBlockToHtml.php";
  include "$LIBRARYPATH/fnCodeBlockFromHtml.php";
  include "$LIBRARYPATH/fnHyperlinkPlainText.php";


  //echo realpath('/apache2/ideas/product-data/lib');
  //echo "The realpath of / is ".realpath('/');
  $bNewFile = false;
  $sFilePath = '';
  $sFileContents = '';
  $aaTextLines = '';
  $sWebPathPrefix = '/ideas';
  $bChmodSucceeded = false;  //-- if php can make the file writeable

  $aaTextLines = file($ERRORTEMPLATE);
  $sErrorTemplateContents = implode('', $aaTextLines);

  $aaTextLines = file($ADMINTEMPLATE);
  $sAdminTemplateContents = implode('', $aaTextLines);



  //-- Convert all file path indicators to forward slashes since this is the
  //-- easiest format for PHP to deal with. Otherwise it is necessary to 'escape'
  //-- all the MS Windows backslashes.
  $sFilePath = $_GET['folder'];

  if ($sFilePath == "")
  {
    $sFilePath = $WEBROOT;
  }

  $sFilePath = str_replace('\\', '/', $sFilePath);
  $sFilePath = preg_replace('#[/]+#', '/', $sFilePath);
  
//  if (substr($sFilePath, 0, 1) != "/")
//  {
//    $sFilePath = "/$sFilePath";  
//  }
  
  
  $sFilePathEncoded = htmlspecialchars($sFilePath);
  $sFilePathUrlEncoded = htmlspecialchars(urlencode($sFilePath));
  $sWebFilePathEncoded = htmlspecialchars(str_replace($WEBDOCUMENTROOT, "", $sFilePath));

  $sFileName = basename($sFilePath);
  $sFileNameEncoded = htmlspecialchars($sFileName);
  $sFileNameUrlEncoded = htmlspecialchars(urlencode($sFileName));

  $debug = "";
  if ($debug == "true")
  {
    echo "
      <pre>
      sFilePath=$sFilePath
      sFileName=$sFileName
      sCurrentDirectory=$sCurrentDirectory
      sCurrrentWebDirectory=$sCurrentWebDirectory
      sWebFilePathEncoded=$sWebFilePathEncoded
      </pre>";
    //exit;
  } //--if




  $sPageTitle = "Choose a Document Folder";
  $sPageContent = "
          = Choose a document folder

      You can use this page to choose a folder on the server
      which contains editable documents.

 
       ";

  $aaFolderList[] = "/home/waggacwc/public_html/refurb/docs/";
  $aaFolderList[] = "/home/waggacwc/public_html/refurb/";
  $aaFolderList[] = "/home/waggacwc/public_html/";

  $sPageContent = fnMessageToHtml($sPageContent);
  $sPageContent = $sPageContent.
    fnArrayToHtmlLinkList(
       $aaFolderList,
       "/refurb/webpad/webpad.php?file=");

  $sOutputPage = fnFillWebTemplate(
     $sAdminTemplateContents, $sPageContent, $sPageTitle);   
  echo $sOutputPage;
  exit;


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

                    